OAuth2 Authorization Code Grant
Last updated
Last updated
NOTE: Authroization Code Grant Type flow requires trusted server. “Authorization Code Grant” in the OAuth2 RFC
Send the user you want to authenticate to your registered redirect URI. An authorization page will ask the user to sign up or log into Pulsoid and allow the user to choose whether to authorize your application/identity system.
Create a <a href="">login</a>
:
Parameters explained:
Name | Type | Description |
---|---|---|
In our example, you request access to read heart rate data and send the user to http://localhost:
If the user authorizes your application, the user is redirected to your redirect URL:
The OAuth 2.0 authorization code is a randomly generated string. It is used in the next step, a request made to the token endpoint in exchange for an access token. In our example, your user gets redirected to:
On your server, get an access token by making this request:
Here is a sample request:
We respond with a JSON-encoded access token. The response looks like this:
In our example:
Note that code can be exchanged for an access token only once.
client_id
string
Your client ID.
redirect_uri
string
Your registered redirect URI. This must exactly match the redirect URI registered in the prior.
response_type
string
Should be always code
scope
string
Comma-separated list of scopes.
state
string
Your unique token, generated by your application. This is an OAuth 2.0 opaque value, used to avoid CSRF attacks. This value is echoed back in the response.