OAuth2 Authentication
Last updated
Last updated
Setup credentials following the instructions on . When you have obtained a client_id
and a client_secret
you can try out OAuth 2.0 resapi/1.0/common/oauth2
the flow goes as follows to get authorized:
Note
OAuth endpoints:
(Resource Owner Authorization endpoint)
(Token Credentials Request endpoint)
User authorization through redirection. First, we will create an authorization URL from the base URL given by Odoo and the credentials previously obtained.
GET /restapi/1.0/common/oauth2/authorize
Request:
Response:
Query Parameters:
client_id – Odoo consumer key
state – Specifies any additional URL-encoded state data to be returned in the callback URL after approval.
redirect_uri – An absolute URL to which the Odoo will redirect the User back when the obtaining User Authorization step is completed.
response_type – This must be code
for this authentication flow.
Request Headers
Response Headers
Status Codes
Fetch an access token from the Odoo using the authorization code obtained during user authorization.
POST /restapi/1.0/common/oauth2/access_token
Request:
Response:
Query Parameters:
client_id – Odoo consumer key
client_secret – Odoo consumer secret
redirect_uri – An absolute URL to which the Odoo will redirect the User back when the obtaining User Authorization step is completed.
code – Authorization code the consumer must use to obtain access and refresh tokens.
grant_type – Value must be authorization_code
for this flow.
Request Headers
Response Headers
Status Codes
– the response content type depends on Accept header
– The OAuth protocol parameters to authenticate.
– this depends on Accept header of the request
– no error
– there’s no resource
– authentication failed
– the response content type depends on Accept header
– The OAuth protocol parameters to authenticate.
– this depends on Accept header of the request
– no error
– there’s no resource
– authentication failed