Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not request access token for. The refresh token could be expired or invali #3

Closed
tobiasmith opened this issue Aug 8, 2022 · 5 comments · Fixed by #5
Closed

Comments

@tobiasmith
Copy link

Hi, once I set OAUTH2 for Exchange Online Mail account in OTOBO, downloading emails will stop with error as bellow. After edit and save mail account and login to Microsoft, error will stop for next hour. In the auth_token table will be a new refresh key with every "edit and save mail account"

Backend ERROR: OTOBO-CGI-00 Perl: 5.32.1 OS: linux Time: Thu Jun 30 17:28:34 2022

Message: CommunicationLog(ID:126465,AccountType:-,AccountID:-,Direction:Incoming,Transport:Email,ObjectLogType:Connection,ObjectLogID:187362)::Kernel::System::MailAccount::POP3 => POP3OAuth2: Could not request access token for XXXX‘. The refresh token could be expired or invalid.

RemoteAddress:
RequestURI: /otobo/index.pl?Action=AdminMailAccount;Subaction=Run;ID=2;ChallengeToken=XXXXX;
Punamu added a commit to Punamu/MailAccount-OAuth2 that referenced this issue Aug 22, 2022
Fixes RotherOSS#3

Removed the `LOWER` SQL functions which prevented an OAuth2 access_token
refresh using the refresh_token stored in the database.
Punamu added a commit to Punamu/MailAccount-OAuth2 that referenced this issue Aug 22, 2022
Fixes RotherOSS#3

Removed the `LOWER` SQL functions which prevented an OAuth2 access_token
refresh using the refresh_token stored in the database.
@Punamu
Copy link
Contributor

Punamu commented Oct 15, 2024

@stefanhaerter Sorry to mention you directly, but since this issue is now open for 2 years is there any chance this could be looked at?

The linked PR fixed the issue for us. As of right now we have to alter the code manually after every update.

@stefanhaerter
Copy link
Contributor

The mention is fine, don't worry - this will definitely been looked at, but as I'm not familiar with Outlook / Exchange at all, I can't give any estimate about this. Your PR looks like a sensible change, but usually we try to make an effort to understand why the code causing the failure was implemented and which possible side effects are to be considered.

I'll provide an update as soon as we have the capacity to review this.

@Punamu
Copy link
Contributor

Punamu commented Oct 15, 2024

Thanks for the update!

I can't answer the "why" but there are some inconsistencies in the code regarding access of the account_type column.
Maybe this helps to speed up the analysis.

The insert happens without a LOWER:

SQL => "INSERT INTO $Self->{TokenTable} (token, account_type, account_id, token_type) "
. "VALUES (?, ?, ?, 'refresh')",

Also these deletes don't have a LOWER either:

@yahikii
Copy link

yahikii commented Feb 13, 2025

Hello, are there any updates to this situation? We also had this issue and fixed it with removing the "LOWER" infront of the "?" like Punamu described. I found the solution back then randomly in this otobo forum post: https://otobo.io/forums/topic/could-not-request-access-token-for-the-refresh-token-could-be-expired-or-invali/

The Issue is still current and I have the feeling that many more people have this issue without having an idea that its such an easy simple solution to fix it. I like to highlight that there is an open pull request with such an easy solution who would solve this issue for everyone. I don't get it why it wasn't implemtented especially as Punamu said the use of the "LOWER" function is so inconsistent. Currently I have implemented a work around for it but it would be nice to someday be able to remove it.

Thank you already for an update to it and I hope this solution can be solved soon 😊

@svenoe svenoe closed this as completed in #5 Feb 14, 2025
@svenoe
Copy link
Contributor

svenoe commented Feb 14, 2025

(Sorry, this package was initially developed by one of our partners for one customer and with adopting it, the responsibility on our end(!) was not decided on clearly. All people have plenty of other things to work on, none of our customers complained, testing it is a hassle,... This is quite clear, though.)

svenoe pushed a commit that referenced this issue Feb 14, 2025
Fixes #3

Removed the `LOWER` SQL functions which prevented an OAuth2 access_token
refresh using the refresh_token stored in the database.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants