# Authenticating to APIs in the frontend

**URL:** <https://community.auth0.com/t/authenticating-to-apis-in-the-frontend/80008>\
**Category:** Get Help\
**Tags:** api, best-practices, auth0\
**Created:** [March 16, 2022, 1:47pm UTC](https://community.auth0.com/t/authenticating-to-apis-in-the-frontend/80008 "2022-03-16T13:47:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abroadhurst](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/abroadhurst/32/31618_2.png) [@abroadhurst](https://community.auth0.com/u/abroadhurst)\
**Post date:** [March 16, 2022, 1:47pm UTC](https://community.auth0.com/t/authenticating-to-apis-in-the-frontend/80008/1 "2022-03-16T13:47:19Z")

</div>

SDK: express-oauth2-jwt-bearer  
SDK Version: 1.1.0  
Node.js: 6.14.15

Once you have secured you APIs, what is most secure method of accessing those APIs from the front end? I seen a SPA app being utilised to access the APIs but is that the correct way?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [March 17, 2022, 11:49pm UTC](https://community.auth0.com/t/authenticating-to-apis-in-the-frontend/80008/3 "2022-03-17T23:49:16Z")

</div>

Hi there @abroadhurst welcome back!

> [@abroadhurst](#):
>
> I seen a SPA app being utilised to access the APIs but is that the correct way?

SPAs are certainly common in terms of front end applications accessing APIs, and we do have a large library of documentation, SDKs, etc. around these frameworks. To answer your question, a SPA can absolutely access an API securely by conforming to OAuth protocols. The following resources may be of use:

> **[Single-Page Applications (SPA) with API](https://auth0.com/docs/get-started/architecture-scenarios/spa-api)**
>
> Explains the architecture scenario where a single-page application (SPA) talks to an API using OpenID Connect (OIDC), and the OAuth 2.0 Implicit Grant Flow, to authenticate users with Auth0.

> **[Auth0 Single-Page App Quickstarts](https://auth0.com/docs/quickstart/spa)**
>
> Browse single-page app quickstarts to learn how to quickly add authentication to your app.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 22, 2022, 9:50pm UTC](https://community.auth0.com/t/authenticating-to-apis-in-the-frontend/80008/4 "2022-04-22T21:50:51Z")

</div>


