Auth0 Home Blog Docs

Little help to link auth0 client with auth0 api

jwt
database

#1

Hi Everyone,

I’ve done the maximum I can alone, I just need a bit of help to complete my system.

Here it what I have done :

  • A website with a database linked to auth0. Users can register and login.
  • A rest api, secured with a JWT token. I can generate a token from my auth0 api, and access API
  • I’ve authorized my auth0 client to access the auth0 api that generate the token (tab Non Interactive Clients)

Now with a user email and password from the website, how can I get a valid token to access the api ?

The aim is I want to sell my api access, so I need my website users to generate their own JWT tokens.

I’m a bit confused in how to achieve this, even that I’m sure auth0 is the way to go.

Thank you for your help


#2

Assuming you have integrated Auth0 with your website, then it should simply be a matter of specifying the identifier of your API configured in Auth0 when requesting the access token.

The resulting token will contain an aud claim with the identifier as its value. You then pass the access token to any API requests you make and have your API backend verify the token and assert that the aud claim matches its identifier.

Please refer to the articles on API authorization for more details.