Ive configured OAuth login and then trying to save user data in DB requested from oauth provider. So I configured run Function on event users . * . sessions . * . create. Is it correct?
Because after it I'm trying to get OAuth provider data (from payload) such as provider name, access_token, userId and so on. Getting current payload from the OAuth: const payload = JSON.parse(process.env.APPWRITE_FUNCTION_EVENT_DATA). But even if session has been deleted on the client side function execution logs say that it's still the same user. Even if user try to login with another OAuth provider. I get current user session using new Account(client).getSession('current') and then accountApi.deleteSession(sessionId). What I did wrong?
Try to simplify:
add OAuth provider (2 for now) -> execute function on users . * . sessions . * . create event -> get function payload -> logout user on client side -> login with another provider -> payload in new executed function still the same as before (for another OAuth provider)
In Appwrite version 1.2.x, process.env isn't the right way to get variables. Would you please try req.variables.APPWRITE_FUNCTION_EVENT_DATA?
See https://appwrite.io/docs/functions#writingYourOwnFunction for more info
You are definitely right <:appwriterocket:823996226894692403> I've found process.env.VAR in the demos for Nodejs, my fault
[SOLVED] Function's payload within OAuth
👀 which demos? are they ours?
oh ya...that repo is archived because it was for our older functions
I'm a little dumb so have to check out some examples to understood the logic 😅
examples are very helpful...just be very careful about using outdated examples.
These are a little newer: https://github.com/open-runtimes/examples
Thanks a lot, very helpful
Recommended threads
- Manual install docs are out of sync with...
I looked into the manual install docs issue for Appwrite 1.9.0 and wanted to share the findings, since this seems to need a bigger docs decision. What I found:...
- SSL certificate issuance failed:
Domain verifies but SSL cert fails, tried different subdomains like .api and .aw, used cname and CAA, no prior CAA existed on website, tried Multiple CAAs at on...
- Migration from Self-Hosted to Cloud seem...
Hello, I'm trying to migrate from my Self-Hosted Appwrite instance to Cloud, and can't figure out what's going wrong. - If I initiate the migration from Cloud...