$ 81.07
Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
Discuss (mail)
|
Community Apps Dependencies | Show |
Lines of code | 1109 |
Technical Name |
api_auth_oauth2 |
License | OPL-1 |
Website | https://ekika.co |
Versions | 16.0 17.0 |
Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
Discuss (mail)
|
Community Apps Dependencies | Show |
Lines of code | 1109 |
Technical Name |
api_auth_oauth2 |
License | OPL-1 |
Website | https://ekika.co |
Versions | 16.0 17.0 |
Api Oauth2
Introduction
This module include authorization-code-grant flow of OAuth2 for API.
How It Works
Auhtorization and Token Related Steps:
- First, client register redirect-uri, which is provided in api record form, to its respected provider
- client has to made request to "/<api>/oauth2/provider/authorize" with its client_id in request-body(json), which returns authorization_url in json-body from response
- when client use this authorization_url, client has to authorize with its respected user, after successful authorization server returns token information, which includes:
- access_token, refresh_token, expires_in, expires_at, scope, token_type, id_token. Note: this differs from provider
- db, login
- if client wants to refresh the token & get access-token then made request to "/<api>/oauth2/token" with its client-id, client-user-identity in request-body(json), which return new token related information
- if client wants to revoke the token then made request to "/<api>/oauth2/revoke" with its client-id, client-user-identity in request-body(json), which revoke the token from authorization server and also delete the client api user record.
- when client want fetch api data using oauth2 method, made http-request using header:
Authorization: Bearer access_token_value
- if access_token in valid then it return response data. and if access_token invalid then client has to refresh the token or authorize the user again.
API Resource Access Steps:
For More Details
Python Request Examples:
1. Client Authorization:
import requests
import json
= "https://easyapi.ekika.app/jsonapiext/oauth2/provider/authorize"
url
= json.dumps({
payload "client_id": "YOUR_CLIENT_ID",
"client_user_identity": "YOUR_UNIQUE_CLIENT_IDENTITY"
})= {
headers 'Content-Type': 'application/json'
}
= requests.request("GET", url, headers=headers, data=payload)
response
print(response.text)
2. Refresh Token:
import requests
import json
= "https://easyapi.ekika.app/jsonapiext/oauth2/token"
url
= json.dumps({
payload "client_id": "YOUR_CLIENT_ID",
"client_user_identity": "YOUR_UNIQUE_CLIENT_IDENTITY"
})= {
headers 'Content-Type': 'application/json'
}
= requests.request("POST", url, headers=headers, data=payload)
response
print(response.text)
3. Revoke Token:
import requests
import json
= "https://easyapi.ekika.app/jsonapiext/oauth2/revoke"
url
= json.dumps({
payload "client_id": "YOUR_CLIENT_ID",
"client_user_identity": "YOUR_UNIQUE_CLIENT_IDENTITY"
})= {
headers 'Content-Type': 'application/json'
}
= requests.request("GET", url, headers=headers, data=payload)
response
print(response.text)
Configuring API-OAuth2 Authentication
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module