As the title suggests, i'm trying to implement Google/OAuth login, but in the server side. To implement other logins in the server side, the suggested way is to hit the login endpoint manually, get the cookies and set those in the server. But in case of OAuth login, the cookies are set in the redirect link that we pass in the OAuth console (i think). So how can i manually control that? I also need to extract the authorization code that's passed by google
Tech Stack: Next.js@13 Version: Appwrite@latest (local)
Hi. I'm getting a project
, key
, and secret
in the URL. but I'm a bit confused what should I do with these? Can you please show/redirect me to a JS example?
they need to be set as a cookie like done here: https://github.com/appwrite/sdk-for-flutter/blob/b6df91102d7f9d22f44185cfd5490b767e58cfd6/lib/src/client_io.dart#L333-L336
Have you looked into how to set a cookie?
u mean the "almost-ssr" code?
No just in general with nextjs
yeah i know that
What are you stuck with for how to set the cookie from the oauth data?
I've implemented it and it works fine. I've got a few things roaming around my head at this moment
- why
auth/oauth2/success
is the only path that works - it's creating an extra endpoint in my app, which is an overhead and it is something that should be worked on imo
- after the OAuth flow completes, google provides a
code
param in the redirect URL (http://localhost/v1/account/sessions/oauth2/callback/google/{PROJECT_ID}
) and I think I'll need that value for further authorization with google services. is there any way to extract that?
auth/oauth2/success
is the default redirect path Appwrite uses to redirect into a mobile app (passing the secret). This is sort of a hack that leverages the oauth2 flow for mobile
I think I'll need that value for further authorization with google services
No. Appwrite uses that code to create the session. Are you looking to make API calls to the oauth provider? If so, call the Appwrite get current session API and look at the providerAccessToken in the reponse. that's an access token from the provider
okay, now i get it. thanks
[SOLVED] How to implement Google/OAuth Login in the server side?
Recommended threads
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...
- custom domain with CloudFlare
Hi all, it seems that CloudFlare has blocked cross-domain CNAME link which made my app hostname which is in CloudFlare, unable to create a CNAME pointing to clo...
- Custom emails
What happen if I use a third party email provider to customize my emails and my plan run out of emails/month? Appwrite emails are used as fallback sending emai...