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
- 1:1 relationship doesn’t sync after re-a...
Hi, I’m trying to use a two-way one-to-one relationship. It works fine when I create a record with the relationship set, and it also works when I unset it. But ...
- Upsert with setting permissions
Hi there, I am using self-hosted appwrite v1.7.4 and trying to use the bulk update stuff that was released with 1.7.x. Unfortunally I found that there is an ser...
- Github connection error - Self Hosted Ap...
I am trying to connect my github account to deploy a project to sites, but Connect to Gtihub button is disabled. I have configured all Env variables needed for...