Hello, so i tried adding my custom oauth server to the provider following https://github.com/appwrite/appwrite/blob/master/docs/tutorials/add-oauth2-provider.md#2-implement-new-provider and i was able to do it.
This doc i believe is outdated a little bit but figured it somehow.
1- So i set up my client in appwrite(check second comment)
1.1- docker compose build && docker compose up -d
2- go to http://localhost/v1/account/sessions/oauth2/kollektor with project id and the response format headers,
which redirects to the correct /authorize in my server then i login there
3- when login is complete and my server redirects to http://localhost/v1/account/sessions/oauth2/kollektor/redirect?project=6408533033ee5dbf1c1f&code=eyJhbG...&state={"success":"http:\/\/localhost\/auth\/oauth2\/success","failure":"http:\/\/localhost\/auth\/oauth2\/failure"}
4- Then i end up in page http://localhost/auth/oauth2/failure Missing Redirect URL Your OAuth login flow is missing a proper redirect URL. Please check the OAuth docs and send request for new session with a valid callback URL.
5- I check the logs of appwrite container:
appwrite | [Error] Timestamp: 2023-03-08T11:56:17+00:00
appwrite | [Error] Method: GET
appwrite | [Error] URL: /v1/account/sessions/oauth2/:provider/redirect
appwrite | [Error] Type: Appwrite\Extend\Exception
appwrite | [Error] Message: Missing ID from OAuth2 provider.
appwrite | [Error] File: /usr/src/code/app/controllers/api/account.php
appwrite | [Error] Line: 460
appwrite | [Error] Timestamp: 2023-03-08T11:56:18+00:00
appwrite | [Error] Method: GET
appwrite | [Error] URL: /v1/account
appwrite | [Error] Type: Appwrite\Extend\Exception
appwrite | [Error] Message: User (role: guests) missing scope (account)
appwrite | [Error] File: /usr/src/code/app/controllers/general.php
appwrite | [Error] Line: 365
the files i changed in the project:
src/Appwrite/Auth/OAuth2/Kollektor.php: https://codefile.io/f/AOuybXldR3AjOv04QEiD app/config/providers.php: https://codefile.io/f/iFZ5Y0rDBx3LW94xrWdz
added icons to console/static/icons/dark console/static/icons/light
My oauth server works fine when i tried it on a nextjs project using standard nextauth package and added custom provider there
so this is the most important error:
appwrite | [Error] Message: Missing ID from OAuth2 provider.
It seems like Appwrite isn't getting the user's ID from the OAuth2 provider.
okay i will check but as far as i saw it gets the user id from /user/me
but it is not called in the server
maybe i have a typo in function getUser(string $accessToken)
I would dump the API response from the server to see what's getting returned
hello, thx again, problem was from my side id was returning as "sub" not "id"
sorry about that
No worries! I'm glad you were able to figure it out! Oauth can be hard to troubleshoot
[SOLVED] Problem with setting up custom oauth2 provider
Recommended threads
- Migrate from cloud to localhost
Hello everyone. I need to migrate my test project from cloud to localhost, however it seems that this is possible only if a self-hosted appwrite instance it's h...
- Realtime with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...
- Can't login or deploy functions in Appwr...
Hello, since i updatet to the appwrite cli 6.1.0 i can't login or deploy functions with the cli. When i call the command: "appwrite get account --verbose" i ge...