Applies to: Workforce tenants External tenants (learn more)
This article explains how to register an application for a protected web API.
For the common steps to register an app, see Quickstart: Register an application with the Microsoft identity platform.
Accepted token versionThe Microsoft identity platform can issue v1.0 tokens and v2.0 tokens. For more information about these tokens, refer to Access tokens.
The token version your API may accept depends on your Supported account types selection when you create your web API application registration in the Azure portal.
After you create the application, you can determine or change the accepted token version by following these steps:
The web API specifies which token version it accepts. When a client requests a token for your web API from the Microsoft identity platform, the client gets a token that indicates which token version the web API accepts.
No redirect URIWeb APIs don't need to register a redirect URI because no user is interactively signed in.
Exposed APIOther settings specific to web APIs are the exposed API and the exposed scopes or app roles.
Scopes and the Application ID URIScopes usually have the form resourceURI/scopeName
. For Microsoft Graph, the scopes have shortcuts. For example, User.Read
is a shortcut for https://graph.microsoft.com/user.read
.
During app registration, define these parameters:
By default, the application registration portal recommends that you use the resource URI api://{clientId}
. This URI is unique but not human readable. If you change the URI, make sure the new value is unique. The application registration portal will ensure that you use a configured publisher domain.
To client applications, scopes show up as delegated permissions and app roles show up as application permissions for your web API.
Scopes also appear on the consent window that's presented to users of your app. Therefore, provide the corresponding strings that describe the scope:
App roles cannot be consented to by a user (as they're used by an application that calls the web API on behalf of itself). A tenant administrator will need to consent to client applications of your web API exposing app roles. See Admin consent for details.
Expose delegated permissions (scopes)To expose delegated permissions, or scopes, follow the steps in Configure an application to expose a web API.
If you're following along with the web API scenario described in this set of articles, use these settings:
Tip
For the Application ID URI, you have the option to set it to the physical authority of the API, for example https://graph.microsoft.com
. This can be useful if the URL of the API that needs to be called is known.
Expose application permissions instead of delegated permissions if your API should be accessed by daemons, services, or other non-interactive (by a human) applications. Because daemon- and service-type applications run unattended and authenticate with their own identity, there is no user to "delegate" their permission.
Expose application permissions (app roles)To expose application permissions, follow the steps in Add app roles to your app.
In the Create app role pane under Allowed member types, select Applications. Or, add the role by using the Application manifest editor as described in the article.
Restrict access tokens to specific clients appsApp roles are the mechanism an application developer uses to expose their app's permissions. Your web API's code should check for app roles in the access tokens it receives from callers.
To add another layer of security, a Microsoft Entra tenant administrator can configure their tenant so the Microsoft identity platform issues security tokens only to the client apps they've approved for API access.
To increase security by restricting token issuance only to client apps that have been assigned app roles:
Microsoft Entra ID will now check for app role assignments of client applications that request access tokens for your web API. If a client app hasn't been assigned any app roles, Microsoft Entra ID returns an error message to the client similar to _invalid_client: AADSTS501051: Application \<application name\> isn't assigned to a role for the \<web API\>_
.
Warning
DO NOT use AADSTS error codes or their message strings as literals in your application's code. The "AADSTS" error codes and the error message strings returned by Microsoft Entra ID are not immutable, and may be changed by Microsoft at any time and without your knowledge. If you make branching decisions in your code based on the values of either the AADSTS codes or their message strings, you put your application's functionality and stability at risk.
Next stepThe next article in this series is App code configuration.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4