Path on authorization server which is used by the client to obtain an access token.
A well defined set of steps to obtain access token from an authorization server
Useful in traditional web apps
https://oauth2server.com/oauth?response_type=code&client_id=CLIENT_ID
&redirect_uri=REDIRECT_URI&scope=photos
https://my-app.com/callback?code=AUTHORIZATION_CODE
https://oauth2server.com/oauth/token?client_id=CLIENT_ID&
client_secret=CLIENT_SECRET&grant_type=authorization_code&
code=AUTHORIZATION_CODE&redirect_uri=CALLBACK_URL
{
"access_token": "ACCESS_TOKEN",
"token_type": "bearer",
"expires_in": 2592000,
"refresh_token": "REFRESH_TOKEN"
}
Useful in browser-based and mobile apps
https://oauth.example.com/authorize?response_type=token
&client_id=CLIENT_ID&redirect_uri=CALLBACK_URL&scope=read
https://my-app.com.com/callback#token=ACCESS_TOKEN
Useful for your website or your mobile app
https://oauth.example.com/token?grant_type=password&
username=USERNAME&password=PASSWORD&client_id=CLIENT_ID
{
"access_token": "ACCESS_TOKEN",
"token_type": "bearer",
"expires_in": 2592000,
"refresh_token": "REFRESH_TOKEN"
}
Useful if applications can access resources on their own
https://oauth.example.com/token?grant_type=client_credentials
&client_id=CLIENT_ID&client_secret=CLIENT_SECRET
{
"access_token": "ACCESS_TOKEN",
"token_type": "bearer",
"expires_in": 2592000,
"refresh_token": "REFRESH_TOKEN"
}
https://oauth.example.com/token?grant_type=refresh_token
&refresh_token=REFRESH_TOKEN
{
"access_token": "ACCESS_TOKEN",
"token_type": "bearer",
"expires_in": 2592000
}
You can create your own custom grants for your own needs.
Using your favourite language or platform, implement custom grant on the authorization server
https://oauth.example.com/token?grant_type=CUSTOM_GRANT
&scope=read&key1=value1&key2=value2
So you have an access token. Now what?
curl -H "Authorization: Bearer RsT5OjbzRn430zqMLgV3Ia" \
https://api.example.com/me
Limiting access to resources
https://oauth.example.com/token?grant_type=GRANT_TYPE&scope=SCOPES
Scopes are listed in the page where the resources owner authorizes the client
A list of client libraries is available on http://oauth.net/2/