auth0.js icon indicating copy to clipboard operation
auth0.js copied to clipboard

How to get the authentication response in querystring instead of hash

Open JohnCoding94 opened this issue 9 years ago • 10 comments

The need is simple, hash aren't transmitted to the server, so universal apps cannot decode the token on the callback unless the params are in querystrings when invoking the redirectUri.

I looked at the parseHash method's source code and it looks like it has been planned to work with both configurations, but i don't see where i can tune this option.

JohnCoding94 avatar Aug 02 '17 10:08 JohnCoding94

Try the different responseMode configurations available in the readme: https://github.com/auth0/auth0.js#auth0webauth

luisrudge avatar Aug 02 '17 13:08 luisrudge

@luisrudge thanks for the link! I didn't see this page.

I just tried, but i am redirected to https://login.eu.auth0.com/login/callback?state=***# instead of my own redirect uri after i sign in on the Auth0 hosted page (as a user), which is an error page (Oops!, something went wrong).

The error i get on this page is unsupported_response_mode: Unsupported response mode: query.

The only thing i changed is adding the responseMode: query, so it looks like this:

const client = new auth0.WebAuth({
  domain: conf.auth0.domain,
  clientID: conf.auth0.clientId,
  redirectUri: conf.auth0.redirectUri,
  audience: 'https://***.eu.auth0.com/userinfo',
  responseType: 'token id_token',
  responseMode: 'query', // the redirect works fine if i don't override this param
  scope: 'openid email'
});

client.authorize();

Any idea about why it is not supported?

JohnCoding94 avatar Aug 03 '17 08:08 JohnCoding94

I have the same issue. I would like to have the response via queryString. Any help will be appreciated

Eomm avatar Oct 13 '17 17:10 Eomm

Why do you need the response via query string?

luisrudge avatar Oct 16 '17 12:10 luisrudge

+1 on this. I have the same issue trying to build an isomorphic application using Nuxt, and ran into the same issue described by @JohnCoding94. responseMode of query seemed like the natural answer documented above, but seems to be causing problems.

davidthor avatar Oct 23 '17 00:10 davidthor

I just confirmed with the backend team and that's responseMode=query is only supported for the code grant flow (responseType=code). I'm updating docs and readme to reflect that: https://github.com/auth0/auth0.js/pull/527 https://github.com/auth0/docs/pull/5187

If you want to read more about the different flows, you can read this article which is very helpful: https://auth0.com/docs/api-auth/which-oauth-flow-to-use

luisrudge avatar Oct 23 '17 16:10 luisrudge

Is there a reason for this? Why would you need to force the hashmode if you could also just return the info as query?

bkniffler avatar Jan 22 '18 15:01 bkniffler

Hey! I would also like to know if there is a reason for not allowing a query responseMode. Do you have any info @luisrudge ?

Errorname avatar Feb 14 '18 16:02 Errorname

yeah. According to the spec, you shouldn't return a token or id_token in the query string to prevent leaks during transport and risks to the privacy of the user.

luisrudge avatar Feb 14 '18 17:02 luisrudge

Thank you for the explanation

Errorname avatar Feb 14 '18 17:02 Errorname