# Auth0 scope with Angular application

**URL:** <https://community.auth0.com/t/auth0-scope-with-angular-application/89570>\
**Category:** Get Help\
**Tags:** spa, api, scopes\
**Created:** [August 29, 2022, 9:48am UTC](https://community.auth0.com/t/auth0-scope-with-angular-application/89570 "2022-08-29T09:48:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaydeeps03](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jaydeeps03/32/36419_2.png) [@Jaydeeps03](https://community.auth0.com/u/Jaydeeps03)\
**Post date:** [August 29, 2022, 9:48am UTC](https://community.auth0.com/t/auth0-scope-with-angular-application/89570/1 "2022-08-29T09:48:48Z")

</div>

Hi Team,

I am exploring Auth0 SDK for angular application. I have created one SPA and API with ‘Machine to Machine’ configuration. I have added couple of scopes in API and same are allowed from SPA application from auth0 dashboard page.

However, with auth0 sdk in angular application we successfully get Authorize code through ‘/authorize’ endpoint but when application make call to ‘oauth/token’ endpoint then we get ‘{“error”:“access\_denied”,“error\_description”:“Unauthorized”}’ error.

Thanks,  
Jaydeep s

---

<div class="post-metadata">

**Author:** ![openbridge-james](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/openbridge-james/32/31303_2.png) [@openbridge-james](https://community.auth0.com/u/openbridge-james)\
**Post date:** [August 29, 2022, 4:10pm UTC](https://community.auth0.com/t/auth0-scope-with-angular-application/89570/2 "2022-08-29T16:10:13Z")

</div>

With the Auth0-Angular library there is an HttpInterceptor called AuthInterceptor iirc. If you use that interceptor when calling your secure API calls you get a JWT token, that can then be used validate a user. If you look at the API quickstarst Node example you’ll see how the JWT token is validated. This gives you the Auth0 user ID (and org id if you are using organizations). You do NOT call /authorize independently on your own.

I just spent the last few hours figuring this out. Using this video

[![](https://global.discourse-cdn.com/auth0/original/3X/d/a/da3104111e44b1263a737e8e4ac943548cadd89b.jpeg "User Profile Info, Protected Routes, and Calling APIs - Authenticating Your Angular Apps Part 2") ](https://www.youtube.com/watch?v=IQf2eyY0wgw)

---

<div class="post-metadata">

**Author:** ![Jaydeeps03](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jaydeeps03/32/36419_2.png) [@Jaydeeps03](https://community.auth0.com/u/Jaydeeps03)\
**Post date:** [August 30, 2022, 9:20am UTC](https://community.auth0.com/t/auth0-scope-with-angular-application/89570/3 "2022-08-30T09:20:04Z")

</div>

Hi,  
Thanks for reply.  
Does it mean I need to create two applications in dashboard one is with necessary type (either web app or single page application) and other is with ‘Machine to Machine’ configuration with respective API app?

I want to achieve something like below…

 ![IS4Discovery](https://global.discourse-cdn.com/auth0/original/3X/2/e/2e0db326a0677f345c16e265d50bbd9e97a532be.jpeg)

---

<div class="post-metadata">

**Author:** ![openbridge-james](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/openbridge-james/32/31303_2.png) [@openbridge-james](https://community.auth0.com/u/openbridge-james)\
**Post date:** [September 12, 2022, 10:09am UTC](https://community.auth0.com/t/auth0-scope-with-angular-application/89570/4 "2022-09-12T10:09:28Z")

</div>

Sorry for the late response, but yes, you have one for the SPA login and one for the API.

---

<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:** [September 12, 2022, 5:47pm UTC](https://community.auth0.com/t/auth0-scope-with-angular-application/89570/5 "2022-09-12T17:47:53Z")

</div>

Hey @Jaydeeps03! Let us know where you landed with this - Thanks for your input @openbridge-james 🙂

---

<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 19, 2024, 10:26pm UTC](https://community.auth0.com/t/auth0-scope-with-angular-application/89570/6 "2024-11-19T22:26:58Z")

</div>

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