Siirry sisältöön
Odoo Menu
  • Kirjaudu sisään
  • Kokeile ilmaiseksi
  • Sovellukset
    Talous
    • Kirjanpito
    • Laskutus
    • Kulut
    • Datataulukot (BI)
    • Asiakirjat
    • Allekirjoita
    Myynti
    • CRM
    • Myynti
    • Kassajärjestelmä myymälään
    • Kassajärjestelmä ravintolaan
    • Tilaukset
    • Vuokraus
    Verkkosivut
    • Verkkosivun Rakennustyökalu
    • Verkkokauppa
    • Blogi
    • Foorumi
    • Livechat
    • Verkko-oppiminen
    Toimitusketju
    • Varastointi
    • Tuotanto
    • Tuotteen elinkaaren hallinta (PLM)
    • Ostot
    • Huolto
    • Laatu
    Henkilöstöhallinto
    • Työntekijät
    • Rekrytointi
    • Vapaat
    • Arvioinnit
    • Suositukset
    • Kuljetuskalusto
    Markkinointi
    • Somemarkkinointi
    • Sähköpostimarkkinointi
    • Tekstiviestimarkkinointi
    • Tapahtumat
    • Markkinoinnin automaatio
    • Kyselyt
    Palvelut
    • Projekti
    • Työaikakirjaukset
    • Kenttähuolto
    • Asiakaspalvelu
    • Suunnittelu
    • Ajanvaraukset
    Tuottavuus
    • Viestintä
    • Hyväksynnät
    • IoT
    • IP-puhe
    • Tietokirjasto
    • WhatsApp
    Kolmannen osapuolen sovellukset Odoo-Studio Odoo-Pilvialusta
  • Toimialat
    Vähittäiskauppa
    • Kirjakauppa
    • Vaatekauppa
    • Huonekaluliike
    • Ruokakauppa
    • Laitteistokauppa
    • Lelukauppa
    Ruoka & Majoitus
    • Baari ja Pubi
    • Ravintola
    • Pikaruoka
    • Majatalo
    • Juomien jakelija
    • Hotelli
    Kiinteistöt
    • Kiinteistönvälitystoimisto
    • Arkkitehtitoimisto
    • Rakentaminen
    • Kiinteistönhallinta
    • Puutarhanhoito
    • Kiinteistön omistajien yhdistys
    Konsultointi
    • Tilitoimisto
    • Odoo-kumppani
    • Markkinointitoimisto
    • Lakitoimisto
    • Osaajahankinta
    • Tilintarkastus & sertifiointi
    Tuotanto
    • Tekstiili
    • Metalli
    • Huonekalut
    • Ruoka
    • Panimo
    • Yrityslahjat
    Terveys & Liikunta
    • Urheiluseura
    • Silmälasiliike
    • Kuntokeskus
    • Hyvinvointialan ammattilaiset
    • Apteekki
    • Kampaamo
    Kaupat
    • Yleismies
    • IT-laitteisto & Tuki
    • Aurinkoenergiajärjestelmät
    • Suutari
    • Siivouspalvelut
    • LVI-palvelut
    Muut
    • Voittoa tavoittelematon järjestö
    • Ympäristötoimisto
    • Mainostaulujen vuokraus  
    • Valokuvaus
    • Leasing-pyörät
    • Ohjelmistojen jälleenmyyjä
    Selaa kaikkia toimialoja
  • Yhteisö
    Opi
    • Kurssit
    • Dokumentaatio
    • Todistukset
    • Koulutus
    • Blogi
    • Podcast
    Kannusta kouluttautumaan
    • Koulutusohjelmat
    • Scale Up! Liiketoimintapeli
    • Vieraile Odoolla
    Hanki ohjelmisto
    • Lataa
    • Vertaile versioita
    • Julkaisut
    Tee yhteistyötä
    • Github
    • Foorumi
    • Tapahtumat
    • Käännökset
    • Ryhdy kumppaniksi
    • Kumppanipalvelut
    • Rekisteröi tilitoimistosi
    Hanki palveluja
    • Löydä kumppani
    • Löydä kirjanpitäjä
    • Varaa asiantuntijatapaaminen
    • Implementaatiopalvelut
    • Asiakasreferenssit
    • Tuki
    • Versionkorotukset
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Varaa demo
  • Hinnoittelu
  • Asiakaspalvelu

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

  • CRM
  • e-Commerce
  • Kirjanpito
  • Varastointi
  • PoS
  • Projekti
  • MRP
All apps
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Kaikki kirjoitukset Ihmiset Merkit
Tunnisteet (Näytä kaikki)
odoo accounting v14 pos v15
Tietoa tästä foorumista
Apua

Automate Oauth refresh?

Tilaa

Saat ilmoituksen, kun tähän viestiin ilmaantuu aktiviteettia

Tämä kysymys on merkitty
mailserveroauth2office365
2 Vastaukset
4036 Näkymät
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
Hylkää
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Paras vastaus

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
Hylkää
Avatar
Lukas Weber
Paras vastaus

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
Hylkää
Nautitko keskustelusta? Älä vain lue, vaan osallistu!

Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!

Rekisteröidy
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
version 14 error conecting office 365
mailserver office365
Avatar
0
huhtik. 21
3325
fetchmail_outlook & microsoft_outlook modules error
email mailserver office365
Avatar
Avatar
1
jouluk. 22
3968
Mail Setup for Odoo 14
mail mailserver office365
Avatar
0
lokak. 21
3444
Is OAuth2 supported in the Odoo 18 Community Edition?
oauth2
Avatar
Avatar
Avatar
2
syysk. 25
3206
Changing the default System Notifications Email in Odoo 17 Ratkaistu
mailserver
Avatar
Avatar
2
marrask. 24
7195
Yhteisö
  • Kurssit
  • Dokumentaatio
  • Foorumi
Avoin lähdekoodi
  • Lataa
  • Github
  • Runbot
  • Käännökset
Palvelut
  • Odoo.sh hosting
  • Tuki
  • Versionkorotus
  • Räätälöidyt kehitykset
  • Koulutus
  • Löydä kirjanpitäjä
  • Löydä kumppani
  • Ryhdy kumppaniksi
Meistä
  • Yrityksemme
  • Tavaramerkki
  • Ota yhteyttä
  • Työpaikat
  • Tapahtumat
  • Podcast
  • Blogi
  • Asiakkaat
  • Oikeudellinen ilmoitus • Yksityisyys
  • Tietoturva
الْعَرَبيّة 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 on kokoelma avoimen lähdekoodin yrityssovelluksia, jotka kattavat kaikki yrityksesi tarpeet: asiakkuudenhallinta eli CRM, verkkokauppa, kirjanpito, varastointi, kassajärjestelmä, projektinhallinta, jne.

Odoon uniikki arvolupaus on olla samanaikaisesti erittäin helppokäyttöinen ja täysin integroitu.

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