OAuth 2.0¶
Introduction¶
OAuth 2.0 is a protocol that lets you create applications that can request access different parts of user profiles. This page describes how to use OAuth 2.0 when accessing a server API from a web server application.
All developers need to register their application before getting started. A registered OAuth application is assigned a unique Client ID and Client Secret. The Client Secret should not be shared.
Access token¶
Refreshing an access token¶
To obtain a new access token, your application needs to send POST request to
https://critiquebrainz.org/ws/1/oauth/token. The request must include the following parameters:
Parameter |
Description |
|---|---|
refresh_token |
The refresh token returned during the authorization code exchange. |
client_id |
Client ID assigned to your application. |
client_secret |
Client secret assigned to your application. |
redirect_uri |
URL where response will be sent. Must match your application configuration. |
grant_type |
Must be set to |
Request might look like this:
POST /ws/1/oauth/token HTTP/1.1
Host: critiquebrainz.org
Content-Type: application/x-www-form-urlencoded
refresh_token=tGzv3JOkF0XG5Qx2TlKWIA&
client_id=yDDvwAzPUnoD8imvTpVm&
client_secret=AFjfpM7Ar1KtD0bnfV5InQ&
redirect_uri=http%3A%2F%2Fwww.example.com%2Fcallback&
grant_type=refresh_token
As long as the user has not revoked the access granted to your application, you will receive response that will look like this:
{
"access_token": "zIYanFZFEjr1zCsicMWpo6",
"expires_in": 3600,
"token_type": "Bearer",
"refresh_token": "PUnoD8im10XG5QxGzv3JO1"
}
Scopes¶
Authorization requests have a limited scope. You should request only the scopes that your application necessarily needs. CritiqueBrainz provides the following scopes:
review- Create and modify reviews.vote- Submit and delete votes on reviews.user- Modify profile info and delete profile.