Authenticate user using omniauth and Facebook for a rails API?

后端 未结 3 1768
抹茶落季
抹茶落季 2021-01-29 19:48

I\'m building a Rails API and have successfully built a way for a user to authenticate using Omniauth Identity.

We simply post to auth/identity/callback from the client,

3条回答
  •  孤独总比滥情好
    2021-01-29 20:26

    To solve this issue the best resource I found is the rails example application in the satellizer github repo : https://github.com/sahat/satellizer/tree/master/examples/server/ruby

    Your satellizer code calls the AuthController.authenticate method. This method uses the oauth model classes for each provider to convert the code you receive into an access token. Then in your user class you can retrieve the user that match the info you got from the provider.

    At the end the controller method returns the jwt token to the client.

    In my case the controller part is a bit different because I also use devise for mail/password authentication but I copy th oauth classes as is and it works like a charm.

提交回复
热议问题