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
- Selfhosted Github App installation
I've followed this guide: https://appwrite.io/docs/advanced/self-hosting/configuration/version-control to connect GitHub to my self-hosted Appwrite instance (1....
- User ID case sensitivity
I see that through REST (and SDK as well), getting a user is not case sensitive. And even though documentation does not clearly state that it is, the wording "V...
- Any way to temporarily bypass the email ...
Hey guys, any way to bypass the email verification to use the accounts again? i need to recover some projects that due to recent changes have been stopped, and ...