#[Solved] (Self-hosted) Microsoft OAuth2 redirect 500 Server Error

13 messages · Page 1 of 1 (latest)

latent cargo
#

Hey,
I am currently working on an OAuth2 login via Microsoft. I have create an application in Microsoft-Entra for the login. I enabled the Microsoft OAuth in Appwrite with the previously created Entra-Application. I also added the redirect URL (http://localhost/v1/account/sessions/oauth2/callback/microsoft/<myprojectId>) given from Appwrite as a Webplatform in Entra.
After the microsoft login i am redirected to an appwrite page (http://localhost/v1/account/sessions/oauth2/microsoft/redirect?code=<msAccessCode>&state=%7B"success"%3A"http%3A%5C%2F%5C%2Flocalhost%5C%2Fauth%5C%2Foauth2%5C%2Fsuccess"%2C"failure"%3A"http%3A%5C%2F%5C%2Flocalhost%5C%2Fauth%5C%2Foauth2%5C%2Ffailure"%2C"token"%3Afalse%7D&session_state=78d13d93-f738-4142-944a-3368e2fa567a&project=<myProjectId>), which displays the following:
{
"message": "Server Error",
"code": 500,
"type": "general_unknown",
"version": "1.5.7"
}

The docker logs are:
appwrite | [Error] Timestamp: 2024-10-23T16:03:00+00:00 appwrite | [Error] Method: GET appwrite | [Error] URL: /v1/account/sessions/oauth2/:provider/redirect appwrite | [Error] Type: TypeError appwrite | [Error] Message: Cannot assign null to property Appwrite\Auth\OAuth2\Microsoft::$tokens of type array appwrite | [Error] File: /usr/src/code/src/Appwrite/Auth/OAuth2/Microsoft.php appwrite | [Error] Line: 63

I have also tried using ngrok with a public address forwarding to localhost but without any success.
I'd appreciate any help. Cheers!

loud zealot
#

CC: @rotund beacon

#

Needed some sort of help

rotund beacon
latent cargo
latent cargo
#

So far I could figure out that it is an issue specifically with microsoft oauth as I have setup a google oauth (for testing purposes) and that worked. So it does not seem to be an oauth issue in general. Unfortunately, the microsoft oauth login is required for me.

latent cargo
#

If nobody has an idea about this issue I was wondering I there is a possible workaround, as the Microsoft OAuth is essential for the application. For example:
I could get a microsoft access token without the use of appwrite. Would it then be at all possible to use that access token to "login" as the user in appwrite?

latent cargo
#

Has anybody got any ideas? I have been completely stuck on this for the last week...

latent cargo
#

@rotund beacon unfortunately this still isn't resolved... I am very sorry for tagging

rotund beacon
latent cargo
#

I have tried this via creating a forwarding with ngrok, which does not seem to work. I will try to launch it on an actual public domain. Maybe that works🤷‍♂️. Thanks for the help!

latent cargo
#

Okay, it seems to work when Appwrite and the front-end application are running on a public domains. Not the best for developing but happy it works!

rotund beacon