# Retrieving access token for third party app

**URL:** <https://community.auth0.com/t/retrieving-access-token-for-third-party-app/89012>\
**Category:** Get Help\
**Created:** [August 18, 2022, 10:01pm UTC](https://community.auth0.com/t/retrieving-access-token-for-third-party-app/89012 "2022-08-18T22:01:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ross1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ross1/32/12835_2.png) [@ross1](https://community.auth0.com/u/ross1)\
**Post date:** [August 18, 2022, 10:01pm UTC](https://community.auth0.com/t/retrieving-access-token-for-third-party-app/89012/1 "2022-08-18T22:01:22Z")

</div>

I’ve been attempting to integrate a third party application with an M2M app following the instructions [here](https://auth0.com/docs/get-started/applications/confidential-and-public-applications/user-consent-and-third-party-applications#scope-descriptions). When testing the OAuth process, I’ve noticed the redirect URL that gets followed after providing access uses a # instead of a ? in the query string URL. This makes it so the access token provided cannot be parsed on the third party server. Just wondering if anyone knows a way to resolve this or if I may be going about this process wrong?

---

<div class="post-metadata">

**Author:** ![john.gateley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john.gateley/32/10879_2.png) [@john.gateley](https://community.auth0.com/u/john.gateley)\
**Post date:** [August 19, 2022, 1:04pm UTC](https://community.auth0.com/t/retrieving-access-token-for-third-party-app/89012/2 "2022-08-19T13:04:09Z")

</div>

Hi @ross1

Something isn’t right - third party apps are for users, and M2M apps are NOT for users.

You shouldn’t be trying to auth to a M2M app this way.

John

---

<div class="post-metadata">

**Author:** ![ross1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ross1/32/12835_2.png) [@ross1](https://community.auth0.com/u/ross1)\
**Post date:** [August 19, 2022, 8:13pm UTC](https://community.auth0.com/t/retrieving-access-token-for-third-party-app/89012/3 "2022-08-19T20:13:57Z")

</div>

Hi John,

Okay, I guess I misunderstood what the different application types were meant for. After switching to a regular web application I’m still encountering the same issue. Any advice on how to get around it would be appreciated!

Thanks,  
Ross

---

<div class="post-metadata">

**Author:** ![john.gateley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john.gateley/32/10879_2.png) [@john.gateley](https://community.auth0.com/u/john.gateley)\
**Post date:** [August 22, 2022, 3:02pm UTC](https://community.auth0.com/t/retrieving-access-token-for-third-party-app/89012/4 "2022-08-22T15:02:25Z")

</div>

Hi @ross1

Good - the next step is to properly get the access token. Is your app a SPA or a regular web app. I am assuming it is a regular web app that has a backend/server component.

You need to use the Auth Code flow, where the backend exchanges a code for the token.

This is normally done behind the scenes with an SDK (or one of our quickstarts).

See the docs here:

> **[Authorization Code Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow)**
>
> Learn how the Authorization Code flow works and why you should use it for regular web apps.

John

---

<div class="post-metadata">

**Author:** ![ross1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ross1/32/12835_2.png) [@ross1](https://community.auth0.com/u/ross1)\
**Post date:** [August 22, 2022, 6:31pm UTC](https://community.auth0.com/t/retrieving-access-token-for-third-party-app/89012/5 "2022-08-22T18:31:21Z")

</div>

Hi John,

Yes the app is a regular web app. I’ve managed to perform the Auth code flow and receive a token, however this token appears to have an expiry. Ideally after the user provides permission to my third party application I’d want to be able to make calls on behalf of the user indefinitely. Is such a thing possible or would this require a different type of application or flow?

Thanks,  
Ross

---

<div class="post-metadata">

**Author:** ![john.gateley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/john.gateley/32/10879_2.png) [@john.gateley](https://community.auth0.com/u/john.gateley)\
**Post date:** [August 23, 2022, 12:57pm UTC](https://community.auth0.com/t/retrieving-access-token-for-third-party-app/89012/6 "2022-08-23T12:57:12Z")

</div>

Hi @ross1

Access tokens cannot be revoked, so an infinite lived access token would be a very bad thing - if it were compromised, the attacker would have access forever.

Access tokens should be short lived, and new ones created either by silent login and the web app session or by using a refresh token.

For 3rd party apps, refresh tokens are probably the way to go. And you can have infinite lived refresh tokens.

John

---

<div class="post-metadata">

**Author:** ![ross1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ross1/32/12835_2.png) [@ross1](https://community.auth0.com/u/ross1)\
**Post date:** [August 24, 2022, 1:16pm UTC](https://community.auth0.com/t/retrieving-access-token-for-third-party-app/89012/7 "2022-08-24T13:16:37Z")

</div>

Hi John,

Okay, I guess refresh tokens are going to be the way to go with this. Thanks for all your help!

Cheers,  
Ross

---

<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, 2024, 6:51pm UTC](https://community.auth0.com/t/retrieving-access-token-for-third-party-app/89012/8 "2024-11-22T18:51:52Z")

</div>

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