Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
2108 Zobrazení

I've discovered that Odoo allows us to authenticate via an HTTP request to the following endpoint:

http://your_odoo_instance.com/web/session/authenticate. However, you need to include specific parameters in the body of the request.


Sample body parameters:


{ "jsonrpc": "2.0", "params": { "db": "odoo_db", "login": "email", "password": "password" } }

For security reasons, I want to replace the password with my API key. I attempted to use the API key in place of the password, like so:


{ "jsonrpc": "2.0", "params": { "db": "odoo_db", "login": "email", "password": "api_key" } }

However, this approach doesn't seem to work.

My question is: Is there a way to authenticate using the API key instead of the password?

I've noticed that most API key usage is tied to CRUD operations, but I want to explore using the API key with Odoo controllers as well.

Any assistance or guidance would be greatly appreciated!

Thank you in advance to anyone who can help!

Avatar
Zrušit
Nejlepší odpověď

Hi Johnny

The /web/session/authenticate​ endpoint only supports passwords This is because it's meant for browers.

See web/controllers/session.py (the magic is in the absence of 'interactive' key in the credential dict)

You should try connecting as the documentation says, using endpoint xmlrpc/2/common and calling method authenticate​. 

See base/models/res_users.py
(login+password converted to credentials by odoo/service/common.py)
(want to know more ? see _check_credentials methods, e.g. these little condition here and there "differentiating" between API keys and regular passwords)

Also: new authentication possibilities since 18.0

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
led 24
2990
4
srp 24
40575
1
kvě 24
1819
5
pro 20
10829
0
čvc 21
3571