My goal: get user role info.
Problem: The call to the roles API is failing, and I’m unsure of how to resolve this issue.
Architecture: Angular 7 + Auth0-spa-js
started app from quickstarter
documentation example
Based on the return from my app’s initial call to the Auth0 Client, I’m getting a subset of user data that does not include the roles array. To get the user’s role I am making a secondary call to my app’s tenant to query the user API to retrieve the roles info.
I’ve stripped the code down to be more generic, but this is my executing logic.
error:
{"statusCode":400,"error":"Bad Request","message":"Bad HTTP authentication header format","errorCode":"Bearer"}
const url = `https://myapp.auth0.com/api/v2//users/${userId}/roles`
return auth0client.getTokenSilently().subscribe(token =>
this.http
.get(url, {
headers: {
Authorization: `Bearer ${token}`
}
})
.subscribe(data => {
console.log(data)
})
)