Oauth1 Authentication
Start with setting up a new consumer by following the instructions on Configuration. When you have obtained a key
and a secret
you can try out OAuth 1.0 resapi/1.0/common/oauth1
the flow goes as follows to get authorized:
Note
OAuth endpoints:
POST {your_Odoo_server_url}/restapi/1.0/common/oauth1/request_token (Temporary Credential Request endpoint)
GET {your_Odoo_server_url}/restapi/1.0/common/oauth1/authorize (Resource Owner Authorization endpoint)
POST {your_Odoo_server_url}/restapi/1.0/common/oauth1/access_token (Token Credentials Request endpoint)
1. Temporary Credential Request
Obtain a request token that will identify you (the consumer) in the next step. At this stage, you will only need your consumer key and secret.
POST /restapi/1.0/common/oauth1/request_token
Request:
Response:
Query Parameters:
oauth_consumer_key – Odoo
consumer key
oauth_nonce – A randomly selected value provided by your application, which is unique for each authorization request. During the OAuth callback phase, your application must check that this value matches the one you provided during authorization. This mechanism is important for the security of your application.
oauth_callback – An absolute URL to which the Odoo will redirect the User back when the Obtaining User Authorization step is completed.
oauth_signature_method – The signature method that the Consumer used to sign the request. The protocol defines three signature methods:
HMAC-SHA1
,RSA-SHA1
, andPLAINTEXT
.oauth_timestamp – The timestamp is expressed in the number of seconds since January 1, 1970 00:00:00 GMT. The timestamp value MUST be a positive integer and MUST be equal to or greater than the timestamp used in previous requests.
oauth_singature – Base64-encoded HMAC-SHA256 signature signed with the consumer’s private key containing all the components of the request and some OAuth value. The signature can be used to verify that the identity URL wasn’t modified because it was sent by the server.
oauth_version – OPTIONAL. If present, the value MUST be 1.0. Odoo assumes the protocol version to be 1.0 if this parameter is not present. Odoo’s response to the non-1.0 value is left undefined.
Request Headers
Response Headers:
Status Codes:
2. Resource Owner Authorization
Obtain authorization from the user (resource owner) to access their protected resources (customers, orders, etc.). This is commonly done by redirecting the user to a specific URL to which you add the request token as a query parameter. Note that not all services will give you a verifier even if they should. Also, the oauth_token given here will be the same as the one in the previous step.
GET /restapi/1.0/common/oauth1/authorize
Request:
Response:
Query Parameters:
oauth_token – OPTIONAL. The Request Token obtained in the previous step.
Request Headers
Response Headers
Status Codes
3. Token Credentials Request
Obtain an access token from Odoo. Save this token as it can be re-used later. In this step, we will re-use most of the credentials obtained up til this point.
POST /restapi/1.0/common/oauth1/access_token
Request:
Response:
Query Parameters
oauth_consumer_key – Odoo
consumer key
oauth_token – The Request Token obtained previously.
oauth_nonce – A randomly selected value provided by your application, which is unique for each authorization request. During the OAuth callback phase, your application must check that this value matches the one you provided during authorization. This mechanism is important for the security of your application.
oauth_signature_method – The signature method that the Consumer used to sign the request. The protocol defines three signature methods:
HMAC-SHA1
,RSA-SHA1
, andPLAINTEXT
.oauth_timestamp – The timestamp is expressed in the number of seconds since January 1, 1970 00:00:00 GMT. The timestamp value MUST be a positive integer and MUST be equal to or greater than the timestamp used in previous requests.
oauth_verifier – The verification code received from Odoo.
oauth_singature – Base64-encoded HMAC-SHA256 signature signed with the consumer’s private key containing all the components of the request and some OAuth value. The signature can be used to verify that the identity URL wasn’t modified because it was sent by the server.
oauth_version – OPTIONAL. If present, the value MUST be 1.0. Odoo assumes the protocol version to be 1.0 if this parameter is not present. Odoo’s response to the non-1.0 value is left undefined.
Request Headers
Response Headers
Status Codes
Last updated