React-admin: Trying to Redirect back from OAuth Server with Access Token in path

Created on 15 Jun 2017  路  9Comments  路  Source: marmelab/react-admin

Hey,

First off, let me say how enjoyable it has been to work with AOR so far. I've been using it for a couple of days and it has made creating my UI a breeze.

I've run into an issue though now with having User's log in. I'm trying to write my own custom login page that is simply a button to redirect to my Authentication Server. This works well so far, but the issue is the round trip back. I need a page for the callback to come to with the token and token information.

I've setup a custom route following the example given in the documents and can reach the callback with the correct logic, but the server is hosting the page on localhost:3000/#/callback instead of on localhost:3000/callback. This means that when I try to have the server redirect back to the callback, it is trying to send an invalid URL since the URL will have 2 # symbols in the call, one that AOR is putting there, and one that is representing the start of my path params.

Are there any examples that have been done to show an OAuth 2.0 authentication workflow? Seems like something that would be pretty popular but I haven't been able to find anything outside of a one liner in the Authentication document saying that OAuth is possible.

Works but invalid URI
http://localhost:3000/#/callback#access_token=ae732...

Expected, doesn't work
http://localhost:3000/callback#access_token=ae732...

Most helpful comment

I also ran into the same problem. As far as I remember, just use import createHistory from 'history/createBrowserHistory'; instead of import createHistory from 'history/createHashHistory'; in your custom Admin.js will do the trick.

For more information see: react-router-redux

All 9 comments

Looking into it a bit more, I guess the reasoning is that AOR is using HashRouter and wasn't providing an option to user BrowserRouter. In one of the upcoming features, I see that you made it customizable at the Admin level. Going to try checking that out.

This seems like it will be fixed with the next version. Unfortunately, I can't figure out how to get npm install marmelade/admin-on-rest#next to work correctly. It will pull the dependency correctly but then it won't run the anymore saying
./src/App.js Module not found: Can't resolve 'admin-on-rest' in 'C:\Source\{project}\src'

Anyone have any work arounds for this issue?

I also ran into the same problem. As far as I remember, just use import createHistory from 'history/createBrowserHistory'; instead of import createHistory from 'history/createHashHistory'; in your custom Admin.js will do the trick.

For more information see: react-router-redux

I also faced the similar problem when integrating with CAS authentication, any examples would be appreciated.

Referencing the next branch is really difficult right now, subscribe to #774 until we manage to fix that.

In the meantime, see https://github.com/marmelab/admin-on-rest#contributing

@liudonghua123 After searching for a while I found these examples by Auth0.

Use the callback route and customize it to your needs.

The admin-on-rest core team doesn't provide support or advice on debugging your own project. We need to focus on writing documentation, fixing bugs, and adding new features.

Instead, we've decided to offload that charge to the community, by moving support to StackOverflow. Ask your question there, you will find helpful people (sometimes from the core team, too). Besides, the response to your question will be easy to find for future developers with a similar problem.

And once you get a response, please continue to hang out on the admin-on-rest channel in StackOverflow. That way, you can help newcomers and share your expertise.

http://stackoverflow.com/questions/tagged/admin-on-rest

@dervos thanks 馃槂

After searching for a while I found these examples by Auth0.

That old link is dead. For anyone looking, this might point you in the right direction:
https://github.com/auth0-samples/auth0-react-samples/tree/master/01-Login

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pixelscripter picture pixelscripter  路  3Comments

waynebloss picture waynebloss  路  3Comments

kikill95 picture kikill95  路  3Comments

rkyrychuk picture rkyrychuk  路  3Comments

fzaninotto picture fzaninotto  路  3Comments