# Allow clients to generate tokens for AWS gateway

**URL:** <https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711>\
**Category:** Get Help\
**Tags:** auth0\
**Created:** [April 7, 2021, 5:29pm UTC](https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711 "2021-04-07T17:29:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mstrudwick](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mstrudwick/32/14222_2.png) [@mstrudwick](https://community.auth0.com/u/mstrudwick)\
**Post date:** [April 7, 2021, 5:29pm UTC](https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711/1 "2021-04-07T17:29:31Z")

</div>

Hi, I’m looking to use auth0 as an authorizer for my AWS gateway.  
I would like my clients to be able to login to auth0 through an interface, if this is successful then it will generate and display to them a token.  
My clients would then be able to use this token as a header when they call my aws gateway, the gateway will then authenticate this token and provide access to my AWS API.

Is this possible with auth0? I can’t see an obvious way to do this in the documentation.

---

<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:** [April 7, 2021, 7:42pm UTC](https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711/3 "2021-04-07T19:42:17Z")

</div>

@mstrudwick

If I understand your request, this should very doable using this guide:

[https://auth0.com/blog/securing-aws-http-apis-with-jwt-authorizers/#Add-a-JWT-Authorizer-to-Your-API](https://auth0.com/blog/securing-aws-http-apis-with-jwt-authorizers/#Add-a-JWT-Authorizer-to-Your-API)

Have you looked at this?

---

<div class="post-metadata">

**Author:** ![mstrudwick](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mstrudwick/32/14222_2.png) [@mstrudwick](https://community.auth0.com/u/mstrudwick)\
**Post date:** [April 7, 2021, 8:39pm UTC](https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711/4 "2021-04-07T20:39:03Z")

</div>

Unfortunately this doesn’t quite fit my use case - auth on the gateway needs to be done through a lambda function.

I also don’t understand how clients will generate their own tokens. Where does the individual client login fit into this?

---

<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:** [April 7, 2021, 8:48pm UTC](https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711/5 "2021-04-07T20:48:50Z")

</div>

There are many JWT libraries that will allow you to validate a token. If you were to use node.js in your Lambda, you could use this library that we manage:

> **[jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken)**
>
> JSON Web Token implementation (symmetric and asymmetric). Latest version: 9.0.2, last published: 3 months ago. Start using jsonwebtoken in your project by running \`npm i jsonwebtoken\`. There are 25803 other projects in the npm registry using...

> [@mstrudwick](#):
>
> I also don’t understand how clients will generate their own tokens. Where does the individual client login fit into this?

What do you mean by _clients_ ? We typically say clients when we are talking about applications. Are you talking about your customers or applications?

---

<div class="post-metadata">

**Author:** ![mstrudwick](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mstrudwick/32/14222_2.png) [@mstrudwick](https://community.auth0.com/u/mstrudwick)\
**Post date:** [April 7, 2021, 8:56pm UTC](https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711/6 "2021-04-07T20:56:13Z")

</div>

By clients I mean customers. I have an API service on AWS, which multiple different customers need access. However, I want to add authentication to this API with tokens. Therefore my clients need to be able to generate a token for my API which they can then use when they call my API.

My ideal situation is:

1. my customer logs in once (auth0?)
2. a token is generated for them, and displayed
3. customer then calls my api with this token
4. my api checks to see if token is valid

---

<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:** [April 7, 2021, 9:03pm UTC](https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711/7 "2021-04-07T21:03:12Z")

</div>

@mstrudwick,

Thanks for providing more context.

Are you aware that tokens expire? You customer will have to replace the token after expiration. They aren’t going to act the same way as an API key that is valid until it is revoked.

Instead, you may want to consider issuing a set of [client credentials](https://auth0.com/docs/flows/client-credentials-flow) to your customer, this is like a username/password for an application, and allows the application to request a new token whenever it is going to call your API. How many customers do you expect to be using your API?

---

<div class="post-metadata">

**Author:** ![mstrudwick](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mstrudwick/32/14222_2.png) [@mstrudwick](https://community.auth0.com/u/mstrudwick)\
**Post date:** [April 7, 2021, 9:15pm UTC](https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711/8 "2021-04-07T21:15:33Z")

</div>

Yes I’m aware that they expire. I was hoping to use refresh tokens to manage this but sounds like that’s not possible.

Client credentials would definitely be another valid option, how do I create client credentials for each customer? Do I have to have a new auth0 application for each customer or can one application support multiple customers?

There’s about more than 10 but less than 100.

---

<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:** [April 7, 2021, 9:20pm UTC](https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711/9 "2021-04-07T21:20:18Z")

</div>

@mstrudwick,

You would create a new M2M application for each customer. That application is linked to the client ID/client secret they use to request tokens.

You may run into some entity limits depending on which plan you are on. The info is here: [Entity Limit Policy](https://auth0.com/docs/policies/entity-limit-policy)

---

<div class="post-metadata">

**Author:** ![mstrudwick](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mstrudwick/32/14222_2.png) [@mstrudwick](https://community.auth0.com/u/mstrudwick)\
**Post date:** [April 7, 2021, 9:25pm UTC](https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711/10 "2021-04-07T21:25:38Z")

</div>

Right that makes sense. Although it would be a bit of a pain having to manage lots of M2M apps, and we’d run into those limits pretty fast.

Thanks for your help anyway. I’m new to auth so I’m sure theres an easier way I’m missing 😃

---

<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:** [April 7, 2021, 9:32pm UTC](https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711/11 "2021-04-07T21:32:14Z")

</div>

No problem! Let me know if you have any questions.

---

<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 27, 2021, 9:11pm UTC](https://community.auth0.com/t/allow-clients-to-generate-tokens-for-aws-gateway/60711/12 "2021-04-27T21:11:31Z")

</div>

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