Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Which requires the user to authenticate and redirects back to the client with an authorization code (Authorization Code grant type) or access token (Implicit grant type).

http://example.com/restful_api/authorize

Which uses the configured Grant Types to return an access token to the client.

http://example.com/restful_api/token

This project aims to create an easy-t-understand and well-tested framework for creating APIs. On this page, we will explain the basics of using phpFox RESTful API such as sending and receiving data, serializing data in HTTP requests, and more.

...

Call the authorize endpoint to get the code.

://example.com/restful_api/authorize?response_type=code&client_id=CLIENT_ID

...

Code Block
bash
bash
$ curl -u CLIENT_ID:CLIENT_SECRET http://example.com/restful_api/token -d 'grant_type=authorization_code&code=AUTHORIZATION_CODE'

...

Setting the query string parameter response_type=token in the authorize endpoint.

http://example.com/restful_api/authorize?response_type=token&client_id=CLIENT_ID&redirect_uri=http://app.example.com/callback

http://app.example.com/callback#access_token=EACCESS_TOKEN&expires_in=86400&token_type=bearer

Send the user credentials directly to receive an access token

Code Block
bash
bash
$ curl -u CLIENT_ID:CLIENT_SECRET http://example.com/restful_api/token -d 'grant_type=password&email=USER_EMAIL&password=USER_PASSWORD'

...

Code Block
bash
bash
$ curl -u CLIENT_ID:CLIENT_SECRET http://example.com/restful_api/token -d 'grant_type=client_credentials'

...

Code Block
bash
bash
$ curl -u CLIENT_ID:CLIENT_SECRET http://example.com/restful_api/token -d 'grant_type=refresh_token&refresh_token=REFRESH_TOKEN'

...

To access resources, you must add access token to the URI Parameters or the header of request.

http://example.com/restful_api/blog=ACCESS_TOKEN

The response data is in JSON format. Read each API for more details.