Nitin Badole
Nitin Badole

Reputation: 505

How to create JWT when a Client needs token for accessing multiple Audience?

I have created AuthorizationServer using OWIN/Katana OAuth 2.0 Authorization Server. It is configured to use JWT as the AccessTokenFormat. The SigningCredentials here are derived from Audience Secret that is unique to each Audience.

I want to build a Client that uses this AuthorizationServer to get a token for using an couple of API's I've built (resource / audience).

I see in OAuth there is no concept of Audience (JWT concept), the only thing closest to this is a Scope. I can pass multiple scopes (audience) from Client but I don't understand how can I create a JWT in this case since multiple Audience are required to be able to validate the resulting token.

Any help or guidance appreciated.

Upvotes: 1

Views: 1549

Answers (1)

MvdD
MvdD

Reputation: 23436

You should be careful not to confuse two different concepts. The Audience claim indicates for who the access token is intended. You can only use it for services that have that value configured in the allowed audiences.

Scopes limit what the client can do with the token on the service. For example, one scope may allow the client to post to your feed, while another scope gives it access to your list of followers.

So you would typically need two different tokens to access two different APIs. That does not mean the user needs to authenticate twice though.

The authentication happens on the authorization server and while the user is still logged in to that server, he/she won't be prompted for credentials again. The user will be prompted for consent the first time they try to access a new API.

Upvotes: 0

Related Questions