react-native-auth0: Bad HTTP authentication header format
We use react-native-auth0 and use Auth0 Management API User endpoints (new Users()). The description of the usage of this function in the document is below:
auth0
.users('user token')
.getUser({id: "user_id"})
.then(console.log)
.catch(console.error);
Description
Our code is below:
auth0
.users({token: credentials.accessToken})
.getUser({id: userInfo.sub})
.then((fullUserInfo) => {
console.log('userUserInfo', fullUserInfo);
})
.catch(err => {
console.log('error-userUserInfo', err);
});
But it showing below error:
Bad HTTP authentication header format
Prerequisites
- Did you check the documentation? _http://auth0.github.io/react-native-auth0/Users.html#.getUser_
- Did you check the Auth0 Community? Yes, but can’t fine any solutino
- Are you reporting this to the correct repository? Yes
- Are there any related or duplicate Issues or PRs for this issue? No duplicate issue find
Environment
Please provide the following:
- React Native Auth0 version : ^1.2.2
- React Native version : 0.54.4
Reproduction
Can anyone please explain the meaning of .users('user token')
. I can’t understand how we send data in replace of user and token. The document is not cleared.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20 (8 by maintainers)
@MSSPL-PiyaleeMaiti In the scope you need to keep the
openid
value and include as wellread:current_user
, or the token won’t be granted access to that call.@lbalmaceda It works for me. Working code is below:
@lbalmaceda Thanks for your response. I already contact with support team. And with help of them, my code is working, and I get the proper response which I want. My code is below post, you can see. Thanks for your help.
@lbalmaceda Thank you. It’s working for me. My final code is below:
😄 👍 ❤️
@lbalmaceda sry, it’s my mistake. Now I correct my code and my code is below:
Now I get error
Error: invalid credentials
. The error is shown when I call getUserInfo2 function and show error in the console log.Instead of requesting audience
https://${Environment.AUTHDOMAIN}/userinfo
try usinghttps://${Environment.AUTHDOMAIN}/api/v2/
(note the trailing slash) and in the scope include as wellread:current_user
. This way the token you get issued should allow you to call the users api.@lbalmaceda My whole code will show you in below:
Below the whole code by which I want to get full user information. Now tell me which is wrong in my code.