Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support authenticate with facebook access token #793

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Charlie-Hua
Copy link
Contributor

@Charlie-Hua Charlie-Hua commented Dec 17, 2016

Added a new condition in OmniAuthCallbacks#render_data_or_redirect to render user data if the OmniAuth strategy name matches 'AccessToken'.

It's supposed to work with lynndylanhurley/ng-token-auth#341 and the omniauth-facebook-access-token gem.

@israelb
Copy link

israelb commented Apr 18, 2017

Hi, @Charlie-Hua, do you have an example about how to use this with a native app? I'm trying to implement this in a project

@Charlie-Hua
Copy link
Contributor Author

@israelb I don't know how to use with native app, but this PR should work if you put access_token=.... in the request params to the route mapping to devise_token_auth/omniauth_callbacks#omniauth_success
You can use rake routes to check which URI it is, for my project it is /auth/:provider/callback and thus /auth/facebook/callback

@lynndylanhurley
Copy link
Owner

@Charlie-Hua - thanks for taking the time to send this PR. Sorry for the delay, I'll take a look ASAP!

Copy link

@thibaultdalban thibaultdalban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR @Charlie-Hua , it is exactly what I need :)
Just a little suggestion to be able to override the response format.

@@ -209,6 +209,10 @@ def render_data_or_redirect(message, data, user_data = {})

# build and redirect to destination url
redirect_to DeviseTokenAuth::Url.generate(auth_origin_url, data.merge(blank: true))

elsif using_access_token_strategy?
render json: { success: true, data: user_data.merge(data).merge({message: message}) }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract this into a dedicated method, so it will be really easy to customize the response format.
Have a look at https://github.com/lynndylanhurley/devise_token_auth/blob/master/app/controllers/devise_token_auth/registrations_controller.rb#L65 for an example.

@zachfeldman
Copy link
Contributor

@lynndylanhurley were you possible close on this one?

@lynndylanhurley
Copy link
Owner

@zachfeldman I'm working to add support to a client to verify that this works as expected. If anyone else has the time to set up a client with usage instructions I'll be happy to check it out.

@zachfeldman
Copy link
Contributor

Cool thanks so much @lynndylanhurley !!

@nantestdeveloper
Copy link

nantestdeveloper commented Dec 1, 2017

I changed /auth/:provider/callback url to api/v1/auth/:provider/callback and set routes for same in routes but getting auth_hash nil for rest api call

@zachfeldman
Copy link
Contributor

@nantestdevoloper is your comment related to this pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants