Zum Inhalt springen
Odoo Menü
  • Anmelden
  • Jetzt gratis testen
  • Apps
    Finanzen
    • Buchhaltung
    • Rechnungsstellung
    • Spesenabrechnung
    • Tabellenkalkulation (BI)
    • Dokumente
    • E-Signatur
    Vertrieb
    • CRM
    • Vertrieb
    • Kassensystem – Shop
    • Kassensystem – Restaurant
    • Abonnements
    • Vermietung
    Websites
    • Website-Builder
    • E-Commerce
    • Blog
    • Forum
    • Livechat
    • E-Learning
    Lieferkette
    • Lager
    • Fertigung
    • PLM
    • Einkauf
    • Wartung
    • Qualität
    Personalwesen
    • Mitarbeiter
    • Personalbeschaffung
    • Abwesenheiten
    • Mitarbeiterbeurteilung
    • Personalempfehlungen
    • Fuhrpark
    Marketing
    • Social Marketing
    • E-Mail-Marketing
    • SMS-Marketing
    • Veranstaltungen
    • Marketing-Automatisierung
    • Umfragen
    Dienstleistungen
    • Projekte
    • Zeiterfassung
    • Außendienst
    • Kundendienst
    • Planung
    • Termine
    Produktivität
    • Dialog
    • Genehmigungen
    • IoT
    • VoIP
    • Wissensdatenbank
    • WhatsApp
    Apps von Drittanbietern Odoo Studio Odoo Cloud-Plattform
  • Branchen
    Einzelhandel
    • Buchladen
    • Kleidergeschäft
    • Möbelhaus
    • Lebensmittelgeschäft
    • Baumarkt
    • Spielwarengeschäft
    Essen & Gastgewerbe
    • Bar und Kneipe
    • Restaurant
    • Fast Food
    • Gästehaus
    • Getränkehändler
    • Hotel
    Immobilien
    • Immobilienagentur
    • Architekturbüro
    • Baugewerbe
    • Immobilienverwaltung
    • Gartenarbeit
    • Eigentümervereinigung
    Beratung
    • Buchhaltungsfirma
    • Odoo-Partner
    • Marketingagentur
    • Anwaltskanzlei
    • Talentakquise
    • Prüfung & Zertifizierung
    Fertigung
    • Textil
    • Metall
    • Möbel
    • Speisen
    • Brauerei
    • Firmengeschenke
    Gesundheit & Fitness
    • Sportklub
    • Brillengeschäft
    • Fitnessstudio
    • Therapeut
    • Apotheke
    • Friseursalon
    Handel
    • Handyman
    • IT-Hardware & -Support
    • Solarenergiesysteme
    • Schuster
    • Reinigungsdienstleistungen
    • HLK-Dienstleistungen
    Sonstiges
    • Gemeinnützige Organisation
    • Umweltschutzagentur
    • Plakatwandvermietung
    • Fotostudio
    • Fahrrad-Leasing
    • Software-Händler
    Alle Branchen ansehen
  • Community
    Lernen
    • Tutorials
    • Dokumentation
    • Zertifizierungen
    • Schulung
    • Blog
    • Podcast
    Bildung fördern
    • Bildungsprogramm
    • Scale-Up! Planspiel
    • Odoo besuchen
    Software anfragen
    • Herunterladen
    • Editionen vergleichen
    • Releases
    Zusammenarbeiten
    • Github
    • Forum
    • Veranstaltungen
    • Übersetzungen
    • Partner werden
    • Dienstleistungen für Partner
    • Buchhaltungsfirma registrieren
    Services anfragen
    • Partner finden
    • Buchhalter finden
    • Einen Experten treffen
    • Implementierungsservices
    • Kundenreferenzen
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Eine Demo erhalten
  • Preiskalkulation
  • Hilfe

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

  • CRM
  • e-Commerce
  • Buchhaltung
  • Lager
  • PoS
  • Projekte
  • MRP
All apps
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Sie müssen registriert sein, um mit der Community zu interagieren.
Alle Beiträge Personen Abzeichen
Stichwörter (Alle anzeigen)
odoo accounting v14 pos v15
Über dieses Forum
Hilfe

Automate Oauth refresh?

Abonnieren

Erhalten Sie eine Benachrichtigung, wenn es eine Aktivität zu diesem Beitrag gibt

Diese Frage wurde gekennzeichnet
mailserveroauth2office365
2 Antworten
4011 Ansichten
Avatar
Onno Filippo

The documentation on connecting Microsoft Outlook 365 explains how to set up the initial oauth authentication, but it doesn't explain how to use a renewal token to automate the renewal of access credentials. I'd like to know how I can make this happen, so that we don't need to do manual maintenence.

0
Avatar
Verwerfen
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Beste Antwort

Hi Onno,

In this case, you can try with the scheduled action to refresh the token. Set up a scheduled action or cron job to run the token renewal logic at regular intervals. This ensures that access credentials are automatically renewed before they expire, minimizing the need for manual maintenance. You have to use the Microsoft Graph API, specifically the OAuth 2.0 token endpoint (https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token), to renew the access token using the refresh token. You'll need to send a POST request to this endpoint with the refresh token and other required parameters to obtain a new access token.



Hope this helps.

1
Avatar
Verwerfen
Avatar
Lukas Weber
Beste Antwort

concerning Office365 and OAuth2 work flow: when Odoo alread has a refresh-token, getting (= refreshing) the access-token is described here

https//learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow@refresh-the-access-token

Now, the Odoo Microsoft Outlook Module (for outgoing mail servers) misses in its implementation, that refreshing the Access-token via the oauth2/v2.0/token Endpoint also delivers an updated refresh-token (have a look at the Microsoft Identity Platform Learn link above).

So in fact, Odoo always uses the same Refresh-Token in the Microsoft Outlook Module, once we got this Token via the "Connect your Outlook Account" on the Outgoing Mailserver Settings Page. In EntraID (Azure) this token has a default lifespan of 3 months, and it can be set to maximum of 12 months.

Thats why the problem with "The refresh token has expired due to inactivity" occurs when using the Microsoft Outlook Module in Odoo.

When inspecting the correspondig code in Odoo e.g. for V14 in odoo/addons/microsoft_outlook/models/microsoft_outlook_mixin.py:_generate_outlook_oauth2_string(), we have there:

(

self.microsoft_outlook_access_token,

self.microsoft_outlook_access_token_expiration,

) = self._fetch_outlook_access_token(self.microsoft_outlook_refresh_token)

And in _fetch_outlook_access_token():

response = self._fetch_outlook_token('refresh_token', refresh_token=refresh_token)

return (

response['access_token'],

int(time.time()) + response['expires_in'],

)

But the response from _fetch_outlook_token() above returns back also an updated refresh_token in the response: response['refresh_token'].

So all we need to do is to overwrrite _fetch_outlook_access_token() with:

response = self._fetch_outlook_token('refresh_token', refresh_token=refresh_token)

return (

response['access_token'],

response['refresh_token'],

int(time.time()) + response['expires_in'],

)

and _generate_outlook_oauth2_string() with:

(

self.microsoft_outlook_access_token,

self.microsoft_outlook_refresh_token,

self.microsoft_outlook_access_token_expiration,

) = self._fetch_outlook_access_token(self.microsoft_outlook_refresh_token)

This updates the refresh-token every time when trying to send an email and the access-token of the outgoing mail server has expired. Now if you want to update the refresh-token independently of sending emails, you would need to create a cron job on the ir.mail.server model with an action like this one:

@api.model

def _update_refresh_token(self):

server = self.search([('use_microsoft_outlook_service', '!=', False)]) or False

server = server[0] if server else False

if server and server.microsoft_outlook_refresh_token:

(

server.microsoft_outlook_access_token,

server.microsoft_outlook_refresh_token,

server.microsoft_outlook_access_token_expiration,

) = server._fetch_outlook_access_token(server.microsoft_outlook_refresh_token)

_logger.info(

'Microsoft Outlook, Outgoing Mailserver '%s': OAuth Refresh-Token Updated via Cron-Job',

(server.name))

return True

In the Python Code of the Cron Job for the model "ir.mail.server" you would then write:

model.._update_refresh_token()

By the way: above overwrites of _fetch_outlook_access_token() and _generate_outlook_oauth2_string() automatically updates the refresh-token also for incoming_imap mail servers when fetching email. Fetching email is already done regurarly by a cron job in Odoo.

0
Avatar
Verwerfen
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!

Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!

Registrieren
Verknüpfte Beiträge Antworten Ansichten Aktivität
version 14 error conecting office 365
mailserver office365
Avatar
0
Apr. 21
3322
fetchmail_outlook & microsoft_outlook modules error
email mailserver office365
Avatar
Avatar
1
Dez. 22
3955
Mail Setup for Odoo 14
mail mailserver office365
Avatar
0
Okt. 21
3438
Is OAuth2 supported in the Odoo 18 Community Edition?
oauth2
Avatar
Avatar
Avatar
2
Sept. 25
3194
Changing the default System Notifications Email in Odoo 17 Gelöst
mailserver
Avatar
Avatar
2
Nov. 24
7175
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Herunterladen
  • Github
  • Runbot
  • Übersetzungen
Dienstleistungen
  • Odoo.sh-Hosting
  • Support
  • Upgrade
  • Individuelle Entwicklungen
  • Bildung
  • Buchhalter finden
  • Partner finden
  • Partner werden
Über uns
  • Unsere Firma
  • Markenwerte
  • Kontakt
  • Karriere
  • Veranstaltungen
  • Podcast
  • Blog
  • Kunden
  • Rechtliches • Datenschutz
  • Sicherheit
الْعَرَبيّة 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 ist eine Suite von Open-Source-Betriebsanwendungen, die alle Bedürfnisse Ihres Unternehmens abdecken: CRM, E-Commerce, Buchhaltung, Lager, Kassensystem, Projektmanagement etc.

Das einzigartige Wertversprechen von Odoo ist, dass es gleichzeitig sehr einfach zu bedienen und voll integriert ist.

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