# Validate Auth token before serving API

**URL:** <https://community.auth0.com/t/validate-auth-token-before-serving-api/60738>\
**Category:** Get Help\
**Created:** [April 7, 2021, 11:37pm UTC](https://community.auth0.com/t/validate-auth-token-before-serving-api/60738 "2021-04-07T23:37:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![admin50](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/admin50/32/12951_2.png) [@admin50](https://community.auth0.com/u/admin50)\
**Post date:** [April 7, 2021, 11:37pm UTC](https://community.auth0.com/t/validate-auth-token-before-serving-api/60738/1 "2021-04-07T23:37:47Z")

</div>

My APP consists of 2 parts, SinglePage / API.  
In the single web page, I’ve implemented the “createAuth0Client” to create/authenticate the user.  
Now I want to validate token/authentication on each API call from that page and to get the user details before serving his request.

I guess I can get the token on the client-side by “auth0.getTokenSilently();” and send it over but how do I verify it?  
Thx

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [April 8, 2021, 12:33pm UTC](https://community.auth0.com/t/validate-auth-token-before-serving-api/60738/3 "2021-04-08T12:33:45Z")

</div>

Hi @admin50,

Welcome to the Community!

In this case, the SPA would not be responsible for validating the Access Token. It will take the Access Token it receives from the `/token` endpoint and store it for API requests, but that is all. The API itself is responsible for validation the Access Token. This way, if someone attempts to call the API outside of the SPA (using Postman or cURL or their own app for example), they would not succeed because the API will validate the token.

Auth0 has several SDKs to handle this validation. You can find examples in the Quickstarts: [Auth0 Backend/API Quickstarts](https://auth0.com/docs/quickstart/backend)

You can find more info about SPA + API authentication here: [Single-Page Applications (SPA) with API](https://auth0.com/docs/architecture-scenarios/spa-api)

---

<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 23, 2021, 12:34pm UTC](https://community.auth0.com/t/validate-auth-token-before-serving-api/60738/4 "2021-04-23T12:34:08Z")

</div>

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