# How to authorize loggedin user from client on server side?

**URL:** <https://community.auth0.com/t/how-to-authorize-loggedin-user-from-client-on-server-side/59428>\
**Category:** Get Help\
**Tags:** auth0-spa-js, jwt\
**Created:** [March 15, 2021, 8:45am UTC](https://community.auth0.com/t/how-to-authorize-loggedin-user-from-client-on-server-side/59428 "2021-03-15T08:45:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yozawiratama](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yozawiratama/32/8051_2.png) [@yozawiratama](https://community.auth0.com/u/yozawiratama)\
**Post date:** [March 15, 2021, 8:45am UTC](https://community.auth0.com/t/how-to-authorize-loggedin-user-from-client-on-server-side/59428/1 "2021-03-15T08:45:14Z")

</div>

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:

1. login using Auth0 SPA
2. get access token fron login
3. send data using access token in header Authorization
4. and verify it in graphql context or express middleware?

```auto
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?

---

<div class="post-metadata">

**Author:** ![cibrax](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/cibrax/32/27644_2.png) [@cibrax](https://community.auth0.com/u/cibrax)\
**Post date:** [March 15, 2021, 8:51pm UTC](https://community.auth0.com/t/how-to-authorize-loggedin-user-from-client-on-server-side/59428/2 "2021-03-15T20:51:46Z")

</div>

Check this article.

> **[Auth0 Node (Express) API SDK Quickstarts: Authorization](https://auth0.com/docs/quickstart/backend/nodejs/01-authorization)**
>
> This tutorial demonstrates how to add authorization to an Express.js API.

Thanks  
Pablo.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 16, 2021, 9:52am UTC](https://community.auth0.com/t/how-to-authorize-loggedin-user-from-client-on-server-side/59428/3 "2021-03-16T09:52:36Z")

</div>

Thanks for sharing that @cibrax !

---

<div class="post-metadata">

**Author:** ![yozawiratama](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yozawiratama/32/8051_2.png) [@yozawiratama](https://community.auth0.com/u/yozawiratama)\
**Post date:** [March 20, 2021, 11:29am UTC](https://community.auth0.com/t/how-to-authorize-loggedin-user-from-client-on-server-side/59428/4 "2021-03-20T11:29:53Z")

</div>

> [@cibrax](#):
>
> Auth0 Node (Express) API SDK Quickstarts: Authorization

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`

```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`

> **[Rate Limit Policy](https://auth0.com/docs/troubleshoot/customer-support/operational-policies/rate-limit-policy)**
>
> Describes Auth0's rate limit policy.

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?

---

<div class="post-metadata">

**Author:** ![yozawiratama](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/yozawiratama/32/8051_2.png) [@yozawiratama](https://community.auth0.com/u/yozawiratama)\
**Post date:** [March 20, 2021, 11:35am UTC](https://community.auth0.com/t/how-to-authorize-loggedin-user-from-client-on-server-side/59428/5 "2021-03-20T11:35:36Z")

</div>

Or may be I need to apply this?

[https://auth0.com/docs/api/authentication?http#authorization-code-flow45](https://auth0.com/docs/api/authentication?http#authorization-code-flow45)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 4, 2021, 11:35am UTC](https://community.auth0.com/t/how-to-authorize-loggedin-user-from-client-on-server-side/59428/6 "2021-04-04T11:35:43Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
