Reputation: 6246
I have a ruby on rails application that currently supports facebook authentication with devise / omniauth.
An iOS client is being built that needs to support facebook authentication also.
My question is, how do I use the access token server side to get the user's email outside of an omniauth callback?
My understanding is that omniauth provides some middleware that on a facebook callback writes an auth hash containing all information to request.env['omniauth.auth']
See: https://github.com/mkdynamic/omniauth-facebook
With an iOS client the flow is a little different, I think:
It is step 4 that I'm not sure how to do.
Essentially once I have an access token how do I get an auth hash manually when I'm not in an omniauth callback?
Thanks for any help.
Upvotes: 0
Views: 370
Reputation: 6246
After much trial and error found the following way to get the user's email using the Koala gem:
@graph = Koala::Facebook::API.new(TOKEN, APP_SECRET)
@graph.get_object('me', :fields => ['email'])
Upvotes: 0