Oaut Token expire time very short

Hi

In 17.0.1 I’ve set up Ouat for email, using Azure. In Azure I’ve set token life to 1 year but in Dolibarr it is only 30 minutes and I can’t figure out how to prolong that time. Beside the short time it works just fine

Any input anyone?

Hi,
i thought that 1 year in Azure was meant for the secret key not the token, the token should regenerating itself when it is needed within dolibarr.

Hi

Thanks. I’m new to this so all input is good input. The token in Dolibarr does not renew itself, it lives 30 minuts and then I have to renew it manually. Shouldn’t there be a Cron of some kind? Pls see the picture below. I have to renew it manually by clicking on “Click here to get a token”

1 Like

OK, it’s not 30 min, it is something else, et changes each time. Anyhow, how to make this run automatically?

it will expire yes, but only if it is not asking, when i try to collect an email, for example with my e-mail collector, it will generate a token automatically, my problem at the moment is, that i have a setup authentication problem, while collecting with the token, i assume a scope problem, when i try to collect it renews the token automatically.
Does your E-Mail Collector work? I would need some Help :slight_smile:

Sorry for my bad english, i am from the german forum :slight_smile:

PS
for the E-Mail Collector i use crontabs in Ubuntu

I’m a native Swedish speaker coming from a French forum, so I think we’ll do well together! I intend to use it to log in when sending emails, and it work fine, but it does not renew the token and I have no idea about how to go further with this. What you write above does not help me as I don’t understand att all how this work.

Could you give me a Step by Step tutorial what you have done, starting in Dolibarr up to Azure, so that i can recreate your Way?

I would compare with my Installation, i Upgrade this morning to 17. 0.1 and have no Problem with the tokens, but with the authentifation when collecting the Mail.

I start in Dolibarr (17.0.1). Pls follow the pictures

image

  1. On OAuth Provider chose Microsoft (for Azure)
  2. In Label, write something why not “DoliBarrToken”

image

“Add” then you have

Keep this open and let’s go to Azure

1 Like

Azure

Chose “App registration”

Then “New registration”

Then you will arrive to the below page. Write something in “Name” then you go down to “Redirect URL” chose “Web” and to the right you paste the string from Dolibarr OAuth config “Use the following URL as the Redirect URI when creating your credentials with your OAuth provider”

“Register”

and you’ll arrive here

To the right click on “Add a certificate or secret”

**then click on “New client secret” and on the right of the screen it pop up where you in Description writes something like “My secret”

image

go to the bottom and click on “Add” and you will see this

copy the values to Blocknotes (I will erase them later so no worry)

image

In the top left in Azure

image

go back to the name you gave to the Token, (in my case “Dolibarr email token”) by clicking on it and you will arrive back to

1 Like

Then in Dolibarr OAuth Services

  1. Copy Application (client) ID to OAuth Client ID
  2. Copy Directory (tennant) ID to OAuth tennant
  3. Go to the stored value in Blocknotes and copy the Value to OAuth secret
  4. in Permissions (Scopes) click the boxes you find suitable
  5. Click on Save and follow the instructions.
  6. You should be up running

And you have to look under Token Manager and create a Token!

Then of course, in the email collector you have to do the right settings for Access type and so on.

1 Like

Great documentation, looks like mine, lets have a look in the e-mail collector, while testing i get an connection setup failed - authenticate error, my token is regenerating every 5 minutes, because my collector runs every 5 minutes, i do not need to do it manually, i tried all scopes, in another forum they told me to change the scopes from https://outlook.office365/IMAP.AccessAsUser.All to Sign in to Outlook

I tried with a nomber of diffrent Scopes, I don’t know what one is the right one, but it works for me but remeber that I don’t use it for collector, if it makes a difference.

My issue is as said, that the Token does not renew and I don’t understand how to make that happen.

1 Like

My Connection setup failed - authenticate disappeared after i removed some scopes from the OAuth-Konfiguration -

The only problem that still exists, after finally receiving mails, they are not being moved to my existing archiv folder.

Have the same problem - anybody has a solution for that?

I gave up to find a solution. I know they have been working some with the Oaut module for te Dolibarr 18 release, but I don’t know what htye have done and 18 is not out yet.

Hi,
i was able to get it working 90%, sending and receiving mails, token generates while collecting mails, the only thing that didn´t work was moving the mail to archive, i was working with version 17.0.1.
After upgrading to 17.0.2 i am not able to collect mails anymore, i can see the anount of mails when i click refresh in the mail collector but get an http 500 error when collecting mails.
In will create a test installation 17.0.1 to find out if it is a problem with the version or a user problem :wink:

1 Like

Hi

Have you tested? For me it is first of all a matter of using the OUATH token for SMTP. I don’t like the idea of having the password stored somewhere so a solution would be great. Is it possible to ping people in to a thread? Like @eldy ?

Hi hassebasse,
sorry had no time for testing 17.0.1, i just checked the smtp with oauth for sending ticket, got an error which i forgot, but it still send the mail without token, then i went and created a token manually, the second test sending mail was successfull, i assume that creating a ticket before sending is a must, i will see what happens when the token expires.

Hi
I’m on 17.0.2.
Now it works for me, it is renewing the token as it should. I found this page Setup EMails — Dolibarr ERP CRM Wiki and it seem to be that I had not checked the box for offline_access, just outlook.office365.com/IMAP.AccessAsUser.All
and
outlook.office365.com/SMTP.Send

Adding offline_access and then making a new connection with Azur, made the difference.

Same problem, but with Google Workspace (gMail). Dodibarr v.18.0.2 generates token for 60 minutes and does not renew it automatically.

Did someone found a solution? @eldy ?