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

Trying to login and redirect to state. Error: "Redirect URI doesn't match original redirect URI" #92

Open
Martin317 opened this issue May 11, 2019 · 2 comments

Comments

@Martin317
Copy link

Martin317 commented May 11, 2019

Hello.
In my Angular app I have a login page and some states.

My objective is:

When I go to some state (e.g. /inicio) and I am not logged in, there are a AuthGuard, It redirect to /login state with a param "returnUrl" (https://localhost:4200/login/?returnUrl=/inicio).
Login state try to login with instagram with this url:
"https://api.instagram.com/oauth/authorize/?client_id=<myclientid>&scope=public_content&hl=en&response_type=code&redirect_uri=" + window.location.origin + "/login/?returnUrl=" + this.returnUrl;"

In this example:

https://api.instagram.com/oauth/authorize/?client_id=<myclientid>&scope=public_content&hl=en&response_type=code&redirect_uri=https://localhost:4200/login/?returnUrl=/inicio

On instagram API I have this url:

https://localhost:4200/login/

On my server I have this:

REST_SOCIAL_OAUTH_ABSOLUTE_REDIRECT_URI = 'https://localhost:4200/login/?returnUrl=/inicio'

It works. But I need a variable returnUrl, becouse I need to redirect to /state/<some_id>
I try with this:
REST_SOCIAL_OAUTH_ABSOLUTE_REDIRECT_URI = 'https://localhost:4200/login/?returnUrl'
REST_SOCIAL_OAUTH_ABSOLUTE_REDIRECT_URI = 'https://localhost:4200/login/?returnUrl='
REST_SOCIAL_OAUTH_ABSOLUTE_REDIRECT_URI = 'https://localhost:4200/login/'
REST_SOCIAL_OAUTH_ABSOLUTE_REDIRECT_URI = 'https://localhost:4200/login'

but it didn't work, always the same error: Authentication process canceled; ; {'error_type': 'OAuthException', 'code': 400, 'error_message': "Redirect URI doesn't match original redirect URI"}
Some idea?
Thanks.

@st4lk
Copy link
Owner

st4lk commented May 12, 2019

@Martin317
You can include the redirect_url param when you are calling backend API. In that case backend will use it in API request. From readme:

At input there is also non-required field redirect_uri. If given, server will use this redirect uri in requests, instead of uri got from settings. This redirect_uri must be equal in front-end request and in back-end request. Back-end will not do any redirect in fact.

Does it help?

@Martin317
Copy link
Author

Thank you!! It seems to work. I had not read that.

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

No branches or pull requests

2 participants