Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Session Expired For /web/session/authenticate access through python

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
sessioncontrollerspython3odoo12
2 Răspunsuri
27794 Vizualizări
Imagine profil
SSS

Hello,

I am trying to access /web/session/authenticate using python as:

>>> import requests
>>> import json
>>> url = "http://localhost:8089/web/session/authenticate"
>>> headers = {'Content-Type':'application/json'}
>>> data = json.dumps({"params":{"db":"test","login":"admin","password":"admin"}})
>>> r = requests.post(url=url,data=data,headers=headers)

but it gives me following error:

@page { margin: 2cm } p { margin-bottom: 0.25cm; line-height: 115% }

b'{"jsonrpc": "2.0", "id": null, "error": {"code": 404, "message": "404: Not Found", "data": {"name": "werkzeug.exceptions.NotFound", "debug": "Traceback (most recent call last):\\n File \\"/usr/local/sampada/eclipse-workspace/odoo12/odoo/http.py\\", line 656, in _handle_exception\\n return super(JsonRequest, self)._handle_exception(exception)\\n File \\"/usr/local/sampada/eclipse-workspace/odoo12/odoo/http.py\\", line 314, in _handle_exception\\n raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])\\n File \\"/usr/local/sampada/eclipse-workspace/odoo12/odoo/tools/pycompat.py\\", line 87, in reraise\\n raise value\\n File \\"/usr/local/sampada/eclipse-workspace/odoo12/odoo/http.py\\", line 1460, in _dispatch_nodb\\n func, arguments = self.nodb_routing_map.bind_to_environ(request.httprequest.environ).match()\\n File \\"/usr/local/lib/python3.6/dist-packages/werkzeug/routing.py\\", line 1563, in match\\n raise NotFound()\\nwerkzeug.exceptions.NotFound: 404: Not Found\\n", "message": "404: Not Found", "arguments": [], "exception_type": "internal_error"}, "http_status": 404}}

After changing config file as dbfilter = test gives me following error:

b'{"jsonrpc": "2.0", "id": null, "error": {"code": 100, "message": "Odoo Session Expired", "data": {"name": "odoo.http.SessionExpiredException", "debug": "Traceback (most recent call last):\\n File \\"/usr/local/sampada/eclipse-workspace/odoo12/odoo/http.py\\", line 656, in _handle_exception\\n return super(JsonRequest, self)._handle_exception(exception)\\n File \\"/usr/local/sampada/eclipse-workspace/odoo12/odoo/http.py\\", line 314, in _handle_exception\\n raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])\\n File \\"/usr/local/sampada/eclipse-workspace/odoo12/odoo/tools/pycompat.py\\", line 87, in reraise\\n raise value\\n File \\"/usr/local/sampada/eclipse-workspace/odoo12/addons/http_routing/models/ir_http.py\\", line 346, in _dispatch\\n cls._authenticate(func.routing[\'auth\'])\\n File \\"/usr/local/sampada/eclipse-workspace/odoo12/odoo/addons/base/models/ir_http.py\\", line 118, in _authenticate\\n getattr(cls, \\"_auth_method_%s\\" % auth_method)()\\n File \\"/usr/local/sampada/eclipse-workspace/odoo12/odoo/addons/base/models/ir_http.py\\", line 91, in _auth_method_user\\n raise http.SessionExpiredException(\\"Session expired\\")\\nodoo.http.SessionExpiredException: Session expired\\n", "message": "Session expired", "arguments": ["Session expired"], "exception_type": "internal_error"}}}

after clearing history, cookies and destroying sessions of user still same error occur


 
0
Imagine profil
Abandonează
Imagine profil
Maduka Sopulu
Cel mai bun răspuns

You need to get the session id and pass it as cookie

here is the code example

parameter = {

            "db": "dbname",

            "login": "admin@gmail.com",

            "password": "admin",    

                        }

 

headers = {'Content-type': 'application/json'}      

AUTH_URL = "http://127.0.0.1:8072/web/session/authenticate/"

data = {

        "jsonrpc": "2.0",

        "params": {

                "login": parameter['login'],

                "password": parameter['password'],

                "db": parameter['db']

            }

        }  

res = rq.post(AUTH_URL, data=json.dumps(data),headers=headers)

session_id = res.cookies["session_id"]

base_url = "127.0.0.1:8072/api/v1/modules/" # your api 

json_data = json.dumps(parameter)

json_headers = {

    "Content-Type": "application/json",

    "Accept": "application/json",

    }

'''cookies = {

    'login': "admin@gmail.com", 

    'password': 'admin',

    'session_id':session_id

    }'''

req = rq.post("http://{}".format(base_url), data = json_data, headers=json_headers, cookies=cookies)

print(req.content) 

1
Imagine profil
Abandonează
Imagine profil
Ravi Gadhia
Cel mai bun răspuns

Hi 
It seems everything is ok and it should work. 
but as error point out "Session expired" it should only occur in case of auth='user' on the route. 
however 'web/session/authenticate' route is auth="none" type so are you sure it's not overridden by another module (it change auth none to user)?

0
Imagine profil
Abandonează
SSS
Autor

Yes I have change auth=none to auth=user. For auth=none work fine but I want authenticate user that is reason I am changing auth=user.how to authenticate user if auth=user?

Ravi Gadhia

auth="user" mean Http layer first check the user is logged in (it has a valid session-id) while auth="none" means it doesn't' check user authentication.

use of route /web/session/authenticate who have user credential can request this route and get a session which used for further communion. so this route must be auth="none" otherwise there is no need to authenticate if a user already login

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
I want to populate Customer/Vendor Many2one field based on Selection Field which has two selection 1.Sale Order, 2.Purchase Order. If it is Sale Order then Many2one field should have Customers from sale.order model and if it is Purchase Order then Many2one field should have Vendors from purchase.order model. v:odoo12 Rezolvat
python3 odoo12
Imagine profil
Imagine profil
Imagine profil
3
dec. 22
4260
how to session expire in odoo?
session odoo12
Imagine profil
0
nov. 22
1908
No data in POST Rezolvat
controllers odoo12
Imagine profil
1
oct. 20
3532
How to make sign up menu in website? Rezolvat
python3 odoo12
Imagine profil
Imagine profil
2
apr. 20
5373
Multi Assign to one task?
python3 odoo12
Imagine profil
Imagine profil
1
apr. 20
4333
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now