# How should I set this up for an API called by SPA or native app?

**URL:** <https://community.auth0.com/t/how-should-i-set-this-up-for-an-api-called-by-spa-or-native-app/148243>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [September 30, 2024, 8:25am UTC](https://community.auth0.com/t/how-should-i-set-this-up-for-an-api-called-by-spa-or-native-app/148243 "2024-09-30T08:25:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris60](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris60/32/60957_2.png) [@chris60](https://community.auth0.com/u/chris60)\
**Post date:** [September 30, 2024, 8:25am UTC](https://community.auth0.com/t/how-should-i-set-this-up-for-an-api-called-by-spa-or-native-app/148243/1 "2024-09-30T08:25:42Z")

</div>

Brand new to Auth0, and 3rd party authorization/authentication in general. This is likely a pretty basic question, but I haven’t been able to find the answer.

I have an API that I need to secure using Auth0. The API is written in .Net Core, but I don’t think that matters for my question. This API will be called by either a web app, or native mobile app. Users will log in to the mobile/web app, then that will call the API. I need to get their login information in the claim that’s passed to the API.

What should I do for this? Do I set this up as an application, or machine-machine API call?

With machine-machine, I can get a test token from my dashboard, but this doesn’t have any user information. Using an Application API, I can log in but don’t get a token to pass to the API for testing.

I don’t currently have a working front end, so how can I get a token with the correct user claims to test the API?

How should I set this up? Is there a really high level overview document that would help me to understand what I should be doing, or a book that anyone recommends?

Thank you!

---

<div class="post-metadata">

**Author:** ![gary598byers](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gary598byers/32/60953_2.png) [@gary598byers](https://community.auth0.com/u/gary598byers)\
**Post date:** [September 30, 2024, 10:39am UTC](https://community.auth0.com/t/how-should-i-set-this-up-for-an-api-called-by-spa-or-native-app/148243/2 "2024-09-30T10:39:24Z")

</div>

Hello,  
To secure your .Net Core API with Auth0 and ensure user login information is passed in the claims, you should set up your API as an **Application API** rather than a machine-to-machine API. Here’s a high-level overview of what you need to do:

1. **Create an API in Auth0** : In the Auth0 dashboard, go to the APIs section and create a new API. This will give you an API identifier (audience) that you will use in your .Net Core application. [Sedgwick](https://www.my-sedgwick.com)
2. **Configure your .Net Core API** : Use the `Microsoft.AspNetCore.Authentication.JwtBearer` package to configure JWT Bearer authentication. Set the authority to your Auth0 domain and the audience to your API identifier.
3. **Get a Token for Testing** : Since you don’t have a working front end yet, you can use the **Resource Owner Password Flow** to get a token with user claims for testing. This flow allows you to programmatically log in a user and get an access token.
4. **Testing Locally** : You can simulate Auth0 locally for development and testing. [Tools like `mock-jwks` can help you create mock JSON Web Tokens (JWTs) for testing purposes]

Best Regards,  
Gary Byers

---

<div class="post-metadata">

**Author:** ![chris60](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris60/32/60957_2.png) [@chris60](https://community.auth0.com/u/chris60)\
**Post date:** [September 30, 2024, 3:10pm UTC](https://community.auth0.com/t/how-should-i-set-this-up-for-an-api-called-by-spa-or-native-app/148243/3 "2024-09-30T15:10:40Z")

</div>

Thank you! Steps 3 & 4 were what I wasn’t real sure on, I’ll take a look at that.

---

<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:** [April 7, 2025, 7:48pm UTC](https://community.auth0.com/t/how-should-i-set-this-up-for-an-api-called-by-spa-or-native-app/148243/4 "2025-04-07T19:48:06Z")

</div>

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