I am attempting to use Rails 5.0.5 API only with devise_token_auth to build a React app. I have the Rails API server running locally on :3001, and my react app (running from within /client folder) is running on :3000.
I am able to register/login/etc. with email/password using axios and API calls, but the oauth is giving me some trouble. It seems that it doesn't want to work with React and the API situation, it loads up a new tab, authenticates with Facebook, then goes to the callback controller on my rails server (:3001). I'm unable to figure out a way for the callback info to be returned to my React app on :3000.
I am able to query facebook manually and receive back the info I need; is there a way to manually create a user based on the Facebook data that will allow me to use devise/devise_token_auth? Do any of you have any better methods for authentication on a React app using Rails API as a backend? I'm pretty new to all of this and not too far into the project, I'm ready to jump ship to a better solution if it exists! Thank you for any information. Please feel free to ask me any questions.
Related
I have a Rails API and a client written in React that is embedded to website A. I want to use single sign-on so that users logging in to website A and going to my React app are automatically logged in to the API.
I am using Devise to manage users and Doorkeeper to handle OAuth2.
Here is the scenario wanted :
User logs in to website A which is a provider
User goes to React app (embedded in website A), some user info is passed by website A to React app
If user is unknown to Rails API, check that provider is website A and store user via Devise
Get access token for this user and user info from API and send back to React App
I cannot add routes to website A so it's not possible to install a usual OAuth2 flow.
My idea was to pass a signature identifying user from website A to the React app, and sending it to the API to authenticate user.
I tried using the doorkeeper-grants_assertion gem but I cannot wrap my head around this problem.
Which grant flow should I use for the user in that case ? How to integrate this strategy to omniauth ?
Any help would be much appreciated.
I want to make an ios app that can create/login users and is linked to a Rails api that uses devise. I've tried using Restkit and AFNetworking but am having some trouble. I understand fetch and pull requests but am not sure how to use tokens to create/login users.
I have a rails api that uses pow built from this tutorial:
http://apionrails.icalialabs.com/book
Does anybody have any advice/examples that can get me going in the right direction?
Basically what I have now are 2 apps, 1 is php and the other one is rails. The rails app is the main app at the moment and contains all the user info, since I'm having a new php based app, I'd like to skip the whole registration and authentication part on php and immediately have it authenticate on the rails app instead via devise.
Are there any good reading materials or anyone can guide me here on how to properly do this?
I am trying to create an ios App that talks to a backend API written in nodejs. The backend also has an accompanying webapp also written in nodejs. The idea is that you can login (using facebook-js) on either the app or the webapp and post things to to.
My question is this, let's say that the user decided to login using the ios App, then call some backend API method to post an article, how do I make this work without essentially forcing the user to login twice?
Not sure if I'm making sense, any help would be greatly appreciated!
As Facebook uses OAuth for the client authentication, it's relatively easy to store the Access Token resulting from the login process somewhere on your server, and use them later.
Have a look at Design for Facebook authentication in an iOS app that also accesses a secured web service
Also, see https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/v2.1 which outlines the login process and the storage of Access Tokens.
I am exploring facebook integration with my rails app and wondering what is the best practice for rails applications.
1 - Is js sdk the better route or the facebooker gem? I would like to allow users to login via facebook, post content/links to their walls, see friend activity in the application, invite fb friends, from the rails app etc.
2 - Can either of these methods be tested locally or do I need a hosted internet app?
3 - I already do fb authentication for login using janrain/rpx-now via authlogic-rpx plugin. Will this have any conflict with the facebooker gem or the fb js sdk. And..in order to use the fb pluging/js sdk/facebooker etc, is it required to do the authentication via those methods or can I authenticate via rpx/janrain but access feeds/friend activity etc from the facebooker gem/js sdk etc?
Thanks
1) I often use both. I find most of the work to be easier using the server side SDK, but we do occasionally use the js one as well. I would check out Facebooker2, it's much more simple than the original Facebooker
2) Both can be used locally, but you do need internet connectivity to talk to Facebook.
3) If you get a valid access token, you can use Facebooker with the RPX stuff. You would need to change the way you do the client setup.