# SPA login, then send data to my own API

**URL:** <https://community.auth0.com/t/spa-login-then-send-data-to-my-own-api/79454>\
**Category:** Get Help\
**Created:** [March 8, 2022, 3:44am UTC](https://community.auth0.com/t/spa-login-then-send-data-to-my-own-api/79454 "2022-03-08T03:44:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vicatcu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vicatcu/32/33754_2.png) [@vicatcu](https://community.auth0.com/u/vicatcu)\
**Post date:** [March 8, 2022, 3:44am UTC](https://community.auth0.com/t/spa-login-then-send-data-to-my-own-api/79454/1 "2022-03-08T03:44:16Z")

</div>

I followed the Angular quick start: [Auth0 Angular SDK Quickstarts: Login](https://auth0.com/docs/quickstart/spa/angular/01-login) and I got all the way through it to the point where I can dump the logged in user$ to the page and have a look at what I get. It looks like I get this `sub` field in the result which I can use to uniquely identify the logged in user.

Is it legit to then pass the value of that `sub` field along to my API routes (e.g. in the payload object of a POST) on my own server to reliably and securely associate the API access with the logged in user? If not is there an article I can read to help me bridge that gap?

---

<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 9, 2022, 6:45pm UTC](https://community.auth0.com/t/spa-login-then-send-data-to-my-own-api/79454/3 "2022-03-09T18:45:05Z")

</div>

Hey there @vicatcu, welcome to the community!

While the `sub` field does indicate a unique user, it’s a small piece of the overall flow . I definitely recommend taking a look at the following architectural overview which outlines the suggested approach to Authentication/Authorization between a SPA app and API as defined by OAuth/OIDC:

> **[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.

Another article that may be of use:

> **[Call Your API from Your Single-Page App](https://auth0.com/docs/microsites/call-api/call-api-single-page-app)**
>
> Everything you need to know to call your API from your single-page app (SPA)

Hope this helps to get you started in the right direction!

---

<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, 7:37pm UTC](https://community.auth0.com/t/spa-login-then-send-data-to-my-own-api/79454/4 "2022-04-22T19:37:02Z")

</div>


