nhost / hasura-auth

Authentication for Hasura.
https://nhost.io
MIT License
382 stars 114 forks source link

Custom handling of google, facebook authentication #532

Closed euvarov closed 3 months ago

euvarov commented 3 months ago

Hello, does anyone know how to add custom handling of side-provider auth request (google e.t.c.). We need to path additional data for user with auth request, but I can't find how to handle it.

Here is example workflow:

  1. User press auth/register via Google
  2. We adding some custom data to request (chosen user language for example)
  3. Hasura receiving the data and handle it. Here we need somehow to catch additional data we sent and store it into database
dbarrosop commented 3 months ago

You should be able to do that yourself. In the user_providers table there is an access token with the requested scopes you can use to get extra information and do whatever you need with it so my advice would be to create an event on insert on that table and write a serverless function that uses the token to retrieve the information and update the user's data via graphql.

Closing as I don't think there is anything to do here but feel free to comment/reopen otherwise.

euvarov commented 3 months ago

Hi @dbarrosop, thank you for the answer, but I'm not sure to what address I should make request with this token? I see this table, but there is only two tokens, provider's name and some more ids with no scopes. What should I call?

Thank you in advance

dbarrosop commented 3 months ago

The access token is for the provider in question so you will have to consult their documentation to know which endpoints/requests you need to perform. There are some examples here for inspiration.

euvarov commented 3 months ago

Great, thank you very much!)