How to do it...

Perform the following steps to carry out user authentication through RPC:

  1. Add the odoo_authenticate.py file. You can place this file anywhere you want because the RPC program will work independently.
  1. Add the following code to the file:
from xmlrpc import client

server_url = 'http://localhost:8069'
db_name = 'test-12'
username = 'admin'
password = 'admin'

common = client.ServerProxy('%s/xmlrpc/2/common' % server_url)
user_id = common.authenticate(db_name, username, password, {})

if user_id:
print("Success: User id is", user_id)
else:
print("Failed: wrong credentials")
  1. Run the following Python script from the Terminal with the following command:
python3 odoo_authenticate.py

This will print a success message with the user ID if you have provided a valid login name and password.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset