Hello I am new in Auth0,
I hava a case, an app using SPA login with Auth0, and I need to authorize that user login on server side.
What I am thinking right now:
- login using Auth0 SPA
- get access token fron login
- send data using access token in header Authorization
- and verify it in graphql context or express middleware?
const auth0Client = await auth.createClient();
console.log(await auth0Client.getTokenSilently()) // return access token
console.log(await auth0Client.getUser());
const token = await auth0Client.getTokenSilently();
fetch('/api', {
method: 'POST',
headers: {
'Authorization': `bearer ${token}`
},
});
on server side, I need to validate it manually and get user data from that token
how to do that?
Thanks for sharing that @cibrax !
Hello @cibrax
I already learn about it because it very googlable
but I need to do that manually not in middleware,
so what I am doing?
I create custom middleware (for now), in my authorization middleware I create this:
auth0.middleware.ts
import Auth0 from 'auth0';
....
var auth0 = new Auth0.AuthenticationClient({
domain: String(process.env.AUTH0DOMAIN),
clientId: String(clientId)
});
const userAuth0: IUserAuth0 = await auth0.getProfile(String(token));
It runs well before, untill I got error 429
after 3 api request, I got that error.
is there any better solution?
because my app have many connection clients, that’s why I need to check authorization from many different clients?
system
Closed
6
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.