# My SPA application getAccessTokenSilently calls brings me to login page

**URL:** <https://community.auth0.com/t/my-spa-application-getaccesstokensilently-calls-brings-me-to-login-page/93546>\
**Category:** Get Help\
**Tags:** get-token-silently, api, login\
**Created:** [November 2, 2022, 6:29am UTC](https://community.auth0.com/t/my-spa-application-getaccesstokensilently-calls-brings-me-to-login-page/93546 "2022-11-02T06:29:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bilal](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bilal/32/39881_2.png) [@bilal](https://community.auth0.com/u/bilal)\
**Post date:** [November 2, 2022, 6:29am UTC](https://community.auth0.com/t/my-spa-application-getaccesstokensilently-calls-brings-me-to-login-page/93546/1 "2022-11-02T06:29:34Z")

</div>

Hey guys.  
I have been on this issue for like 2 weeks and can’t get my head around this. Hence, posting here for some expert opinion.  
So the scenario is that I would like my users to log in to my application by custom login flow. For this I am calling this api with this payload.

```auto
const data = {
			method: 'POST',
			url: 'https://XXX/oauth/token',
			headers: { 'content-type': 'application/json' },
			data: new URLSearchParams({
				grant_type: 'password',
				username: email,
				password: password,
				audience: XXX',
				scope: 'openid profile email read:users update:users create:users create:connections',
				client_id: AUTH0_CLIENT_ID,
			}),
		};

```

Since my application is SPA so in return I get a response like this.  
`{"access_token":"token","id_token":"token","scope":"openid profile email","expires_in":86400,"token_type":"Bearer"}`

After when I redirect my application to home page which is wrapped in an auth HOC it redirects me to login page of auth0. This is what I am getting on logs.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/2/b/2ba8f05728d20110862bcefd24e61b30050f5803.png)

I would appreciate any help on this please.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [November 7, 2022, 8:14pm UTC](https://community.auth0.com/t/my-spa-application-getaccesstokensilently-calls-brings-me-to-login-page/93546/3 "2022-11-07T20:14:48Z")

</div>

Hi @bilal,

Assuming you are getting management API tokens here, you are opening your Auth0 instance up to tampering with this flow.

A user could easily grab the access token and read/update your entire user database.

The resource owner password flow is easily misused and is not recommend unless you are fully aware of the risks.

> [@bilal](#):
>
> After when I redirect my application to home page which is wrapped in an auth HOC it redirects me to login page of auth0. This is what I am getting on logs.

Silent auth relies on an existing session to authenticate. This is usually in the form of an Auth0 Cookie. You can look at the request to see if the correct cookie is attached to the request.

---

<div class="post-metadata">

**Author:** ![bilal](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bilal/32/39881_2.png) [@bilal](https://community.auth0.com/u/bilal)\
**Post date:** [November 8, 2022, 12:31pm UTC](https://community.auth0.com/t/my-spa-application-getaccesstokensilently-calls-brings-me-to-login-page/93546/4 "2022-11-08T12:31:34Z")

</div>

Hey @dan.woda . Thank you for the detail clarification. And yes, you are right, doing things like this has a great chance of exposing my application to intruders.

I’ll try to think something else

---

<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:** [November 22, 2022, 12:32pm UTC](https://community.auth0.com/t/my-spa-application-getaccesstokensilently-calls-brings-me-to-login-page/93546/5 "2022-11-22T12:32:15Z")

</div>

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