Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

API authenticate to odoo with token

I want to authenticate to Odoo from an express application using token. I am using odoo-xmlrpc node module to connect Odoo with my express app. Odoo requires users of the API to be authenticated before they can use any other API. And this node module provides this function

     const odoo = new Odoo({
      url: config.odooUrl,//odoo url
      db: config.odooDB,//odoo db path
      username: "[email protected]",
      password: "john_pass123"
    });
      odoo.connect(function(err, uid) {
      if (err) {
        errors.auth = "invalid cridentials";

        return res.status(400).send(errors);
      }
      //execute something from/to odoo server
     })

The problem is, I have to enter the user's credentials every time I want to execute an Odoo command. And if I store the user's password it would be stored as a plain text. My question is, is their token-based authentication to Odoo that can be used through API. Or any other alternative solution to my problem

like image 866
ben Avatar asked Jul 12 '26 05:07

ben


1 Answers

Currently in Odoo unfortunatelly there is no good solution to this. There is work in progress for support for api token access and 2-factor authentication in this pull request: https://github.com/odoo/odoo/pull/33928.

There are also multiple Odoo rest api modules in app store that support token authentication. You can find these with seach ”rest api” or ”token”. To me none of these have been perfect for my use-cases. I look forward to get native support for this in Odoo Community.

like image 162
Veikko Avatar answered Jul 13 '26 18:07

Veikko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!