Auth API Key
Ini merupakan modul Odoo agar client bisa login menggunakan API Key yang
dikirim melalui header HTTP API-KEY
.
API Key yang dimaksud dibuat melalui menu Preferensi, Keamanan Akun, KUNCI API
BARU. Pada Nama kunci Anda tulis bebas misalnya: H2H ISO8583
, lalu klik
BUAT KEY.
Adapun contoh controller-nya sebagai berikut:
from odoo import http from odoo.http import request class AvailableInvoices(http.Controller): @http.route(['/hello-world'], type='json', auth='api_key') def show(self, **kwargs): return dict(uid=request.env.user.id, message='Hello world.')
Lalu ini contoh client menggunakan curl
:
curl --header "Content-Type: application/json" \ --header "API-KEY: 5ed9ca599bdd1a97f5e05a8e011e440b528a372e" \ --data "{}" http://localhost:8069/hello-world
Teruji di Odoo 16.