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
- Selfhost - Starting Docker containers fa...
I am stuck at installing appwrite. Specifically, the containers dont want to start up. The images are downloaded and ready. Dockhand is reporting containers st...
- It says domain already used but I have d...
I accidentally deleted the project in which I used my domain originally (orexia.app) from name.com. Now I am trying to add it to a different project and it says...
- Is this normal in the self host custom d...
when i try to add custom domain to the project did not see this in 1.8.0 ok when pressed the retry it says "DNS verification failed with resolver 8.8.8.8. Domai...