Create identityProvider

Namespace: microsoft.graph

Important

APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.

Create an identity provider object that is of the type specified in the request body.

Among the types of providers derived from identityProviderBase, you can currently create a socialIdentityProvider resource in Microsoft Entra ID. In Azure AD B2C, this operation can currently create a socialIdentityProvider, openIdConnectIdentityProvider, or an appleManagedIdentityProvider resource.

This API is available in the following national cloud deployments.

Global service US Government L4 US Government L5 (DOD) China operated by 21Vianet

Permissions

Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

Permission type Least privileged permissions Higher privileged permissions
Delegated (work or school account) IdentityProvider.ReadWrite.All Not available.
Delegated (personal Microsoft account) Not supported. Not supported.
Application IdentityProvider.ReadWrite.All Not available.

The work or school account needs to belong to at least the External Identity Provider Administrator Microsoft Entra role.

HTTP request

POST /identity/identityProviders

Request headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.
Content-Type application/json. Required.

Request body

In the request body, provide a JSON representation of socialIdentityProvider object in Microsoft Entra ID.

In Azure AD B2C provide a JSON representation of socialIdentityProvider, openIdConnectIdentityProvider, or an appleManagedIdentityProvider object.

All the properties listed in the following tables are required.

socialIdentityProvider object

Property Type Description
clientId String The client identifier for the application obtained when registering the application with the identity provider.
clientSecret String The client secret for the application that is obtained when the application is registered with the identity provider. This is write-only. A read operation returns ****.
displayName String The display name of the identity provider.
identityProviderType String For a B2B scenario, possible values: Google, Facebook. For a B2C scenario, possible values: Microsoft, Google, Amazon, LinkedIn, Facebook, GitHub, Twitter, Weibo, QQ, WeChat.

openIdConnectIdentityProvider object

Property Type Description
clientId String The client ID for the application obtained when registering the application with the identity provider.
clientSecret String The client secret for the application obtained when registering the application with the identity provider. The clientSecret has a dependency on responseType.
  • When responseType is code, a secret is required for the auth code exchange.
  • When responseType is id_token the secret is not required because there is no code exchange—the id_token is returned directly from the authorization response.
displayName String The display name of the identity provider.
domainHint String The domain hint can be used to skip directly to the sign in page of the specified identity provider, instead of having the user make a selection among the list of available identity providers.
claimsMapping claimsMapping After the OIDC provider sends an ID token back to Microsoft Entra ID, Microsoft Entra ID needs to be able to map the claims from the received token to the claims that Microsoft Entra ID recognizes and uses. This complex type captures that mapping.
metadataUrl String The URL for the metadata document of the OpenID Connect identity provider. Every OpenID Connect identity provider describes a metadata document that contains most of the information required to perform sign-in. This includes information such as the URLs to use and the location of the service's public signing keys. The OpenID Connect metadata document is always located at an endpoint that ends in .well-known/openid-configuration. Provide the metadata URL for the OpenID Connect identity provider you add.
responseMode String The response mode defines the method used to send data back from the custom identity provider to Azure AD B2C. Possible values: form_post, query.
responseType String The response type describes the type of information sent back in the initial call to the authorization_endpoint of the custom identity provider. Possible values: code , id_token , token.
scope String Scope defines the information and permissions you are looking to gather from your custom identity provider.

appleIdentityProvider object

Property Type Description
displayName String The display name of the identity provider.
developerId String The Apple developer identifier.
serviceId String The Apple service identifier.
keyId String The Apple key identifier.
certificateData String The certificate data which is a long string of text from the certificate, can be null.

Response

If successful, this method returns a 201 Created response code and a JSON representation of a socialIdentityProvider object in the response body for a Microsoft Entra tenant.

For an Azure AD B2C tenant, this method returns a 201 Created response code and a JSON representation of a socialIdentityProvider, openIdConnectIdentityProvider, or an appleManagedIdentityProvider object in the response body.

If unsuccessful, a 4xx error will be returned with specific details.

Examples

Example 1: Create a specific social identity provider (Microsoft Entra ID and Azure AD B2C)

Request

The following example shows a request.

POST https://graph.microsoft.com/beta/identity/identityProviders
Content-type: application/json

{
  "@odata.type": "microsoft.graph.socialIdentityProvider",
  "displayName": "Login with Amazon",
  "identityProviderType": "Amazon",
  "clientId": "56433757-cadd-4135-8431-2c9e3fd68ae8",
  "clientSecret": "000000000000"
}

Response

The following example shows the response.

Note: The response object shown here might be shortened for readability.

HTTP/1.1 201 Created
Content-type: application/json

{
    "@odata.type": "microsoft.graph.socialIdentityProvider",
    "id": "Amazon-OAUTH",
    "displayName": "Login with Amazon",
    "identityProviderType": "Amazon",
    "clientId": "56433757-cadd-4135-8431-2c9e3fd68ae8",
    "clientSecret": "000000000000"
}

Example 2: Create a specific OpenID Connect identity provider (only for Azure AD B2C)

Request

The following example shows a request.

POST https://graph.microsoft.com/beta/identity/identityProviders
Content-type: application/json

{
  "@odata.type": "microsoft.graph.openIdConnectIdentityProvider",
    "displayName": "Login with the Contoso identity provider",
    "clientId": "56433757-cadd-4135-8431-2c9e3fd68ae8",
    "clientSecret": "12345",
    "claimsMapping": {
        "userId": "myUserId",
        "givenName": "myGivenName",
        "surname": "mySurname",
        "email": "myEmail",
        "displayName": "myDisplayName"
    },
    "domainHint": "mycustomoidc",
    "metadataUrl": "https://mycustomoidc.com/.well-known/openid-configuration",
    "responseMode": "form_post",
    "responseType": "code",
    "scope": "openid"
}

Response

The following example shows the response.

Note: The response object shown here might be shortened for readability.

HTTP/1.1 201 Created
Content-type: application/json

{
  "@odata.type": "microsoft.graph.openIdConnectIdentityProvider",
  "id": "OIDC-V1-MyTest-085a8a0c-58cb-4b6d-8e07-1328ea404e1a",
  "displayName": "Login with the Contoso identity provider",
  "clientId": "56433757-cadd-4135-8431-2c9e3fd68ae8",
  "clientSecret": "12345",
  "claimsMapping": {
      "userId": "myUserId",
      "givenName": "myGivenName",
      "surname": "mySurname",
      "email": "myEmail",
      "displayName": "myDisplayName"
  },
  "domainHint": "mycustomoidc",
  "metadataUrl": "https://mycustomoidc.com/.well-known/openid-configuration",
  "responseMode": "form_post",
  "responseType": "code",
  "scope": "openid"
}

Example 3: Retrieves Apple identity provider (only for Azure AD B2C)

Request

The following example shows a request.

POST https://graph.microsoft.com/beta/identity/identityProviders
Content-type: application/json

{
  "@odata.type": "microsoft.graph.appleManagedIdentityProvider",
  "displayName": "Sign in with Apple",
  "developerId": "UBF8T346G9",
  "serviceId": "com.microsoft.rts.b2c.test.client",
  "keyId": "99P6D879C4",
  "certificateData": "******"
}

Response

The following example shows the response.

Note: The response object shown here might be shortened for readability.

HTTP/1.1 201 Created
Content-type: application/json

{
  "@odata.type": "microsoft.graph.appleManagedIdentityProvider",
  "id": "Apple-Managed-OIDC",
  "displayName": "Sign in with Apple",
  "developerId": "UBF8T346G9",
  "serviceId": "com.microsoft.rts.b2c.test.client",
  "keyId": "99P6D879C4",
  "certificateData": "******"
}