Closed 22Viig closed 5 years ago
Hi @22Viig,
I think this part should probably be omitted from the quickstart documentation, thanks for the heads up.
You cannot retrieve the ID token from the SDK, as it's not a recommended thing to do (see this issue on the matter and why we won't be exposing it without a good use-case.
What's the situation in which you need the ID token?
I need the JWT to send it to an api server that implements jwt authentication mechanism (mechanism that uses the same key and algorithm of Auth0 to decrypt the jwt ). The server is an API server for mongodb, created with RESTHeart.
The idea is to let my users get authenticated on my website via Auth0, get the id_token and call the api server (passing the id_token/jwt) to get some data.
Maybe can I call some auth0 api to get the id_token?
@22Viig If it's just a JWT you need, you can send the access token. You can get this from the SDK using the getTokenSilently
function. I've had a quick look through the RESTHeart docs and I can't see anywhere where it says that you need the ID token specifically, so this should work for you.
To get an access token in JWT format from Auth0, you need to supply an audience
parameter when creating the Auth0 client. Everything you need should be in this tutorial for calling APIs. The only difference is that you're calling someone else's API instead of your own, so you can skip the parts about creating your own Express server.
Hope that helps!
Thanks @stevehobbsdev , I used the getTokenSilently
function with the audience
in the auth configuration the get the JWT.
I have still a couple of questions to you
@22Viig
It should be noted though, that auth0-spa-js
only supports tokens using the RS256 algorithm.
Written in the documentation:
How can I get the id_token ? I need the encoded JWT . Thanks