Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Discuss
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

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

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
sessioncontrollerspython3odoo12
2 Replies
27763 Tampilan
Avatar
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
Avatar
Buang
Avatar
Maduka Sopulu
Jawaban Terbai

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
Avatar
Buang
Avatar
Ravi Gadhia
Jawaban Terbai

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
Avatar
Buang
SSS
Penulis

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

Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
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 Diselesaikan
python3 odoo12
Avatar
Avatar
Avatar
3
Des 22
4258
how to session expire in odoo?
session odoo12
Avatar
0
Nov 22
1908
No data in POST Diselesaikan
controllers odoo12
Avatar
1
Okt 20
3527
How to make sign up menu in website? Diselesaikan
python3 odoo12
Avatar
Avatar
2
Apr 20
5364
Multi Assign to one task?
python3 odoo12
Avatar
Avatar
1
Apr 20
4324
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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