Link APIs
Overview
This API has been available since 1.28.0
This page contains the APIs that are used to manage Links that establish a relationship between a FusionAuth User and an Identity Provider.
Link a User
This API is used to create a link between a FusionAuth User and a user in a 3rd party identity provider. This API may be useful when you already know the unique Id of a user in a 3rd party identity provider and the corresponding FusionAuth User.
Request
This API has been available since 1.43.0
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
A optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.
Please note, that this value will always be overwritten during login to reflect the most current information from the identity provider. In most cases this value will be an email address or username.
The Id of the identify provider that will be linked to the User.
The Id for the user that is provided by the upstream identity provider. This is the value that will allow FusionAuth to link this User on future logins. This value is expected to be immutable.
The unique Id of the FusionAuth User that is being linked to the identity provider.
The token returned from the identity provider. This is treated as an opaque token as the type varies by identity provider, this value may not be returned by all identity providers. When provided, this token is typically a long lived access or refresh token, but consult individual identity provider documentation for specifics.
{
"identityProviderLink": {
"displayName": "richard@piedpiper.com",
"identityProviderId": "f50dbb83-4cc2-4e5e-aece-9efe068bddd9",
"identityProviderUserId": "42",
"userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}
}
Deprecated in version 1.43.0.
While this API is still functional, its usage is discouraged. When available please use the Link a User endpoint which takes a different request body.
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
An optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.
Please note, that this value will always be overwritten during login to reflect the most current information from the identity provider. In most cases this value will be an email address or username.
The Id of the identity provider.
The Id for the User that is provided by the identity provider. This is the value that will allow FusionAuth to link this user on future logins. This value is expected to be immutable.
The FusionAuth Id of the User that is being linked to the identity provider.
{
"displayName": "richard@piedpiper.com",
"identityProviderId": "f50dbb83-4cc2-4e5e-aece-9efe068bddd9",
"identityProviderUserId": "42",
"userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
}
Response
Response CodesCode | Description |
---|---|
200 | The request was successful. The response will contain a JSON body. |
400 | The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
504 | One or more Webhook endpoints returned an invalid response or were unreachable. Based on the transaction configuration for this event your action cannot be completed. A stack trace is provided and logged in the FusionAuth log files. |
Response Body
A optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.
Please note, that this value will always be overwritten during login to reflect the most current information from the identity provider. In most cases this value will be an email address or username.
The unique Id of the identity provider.
The name of the identity provider.
The type of the identity provider.
The Id for the User that is provided by the identity provider.
The instant the Link was created.
The last instant of the User’s most recent login to the identity provider linked Application.
The Id of the Tenant that this User belongs to.
The token returned from the identity provider. This is treated as an opaque token as the type varies by identity provider, this value may not be returned by all identity providers. When provided, this token is typically a long lived access or refresh token, but consult individual identity provider documentation for specifics.
The unique Id of the FusionAuth User that is linked to the identity provider.
{
"identityProviderLink": {
"displayName": "richard@piedpiper.com",
"identityProviderId": "f50dbb83-4cc2-4e5e-aece-9efe068bddd9",
"identityProviderName": "My OpenIDConnect Identity Provider",
"identityProviderType": "OpenIDConnect",
"identityProviderUserId": "42",
"insertInstant": 1623183147998,
"lastLoginInstant": 1623183152224,
"tenantId": "30663132-6464-6665-3032-326466613934",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
}
}
Complete a pending Link
This API is used complete a pending link. If an identity provider is configured with a linking strategy of Create a pending link
, a pendingLinkId
will be returned by the Identity Provider API (see the Complete the Login
section for each respective IdP). This value can be used in the request below.
Request
Available Since Version 1.43.0
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
The pending identity provider link Id.
The unique Id of the FusionAuth User that is being linked to the identity provider.
{
"pendingIdPLinkId": "elY3lKxvCQvsH_kfEMmBNLIl6TmydtCrNjHpFgVdxb8",
"identityProviderLink": {
"userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
}
}
Deprecated in version 1.43.0.
While this API is still functional, its usage is discouraged. When available please use the Complete a Pending Link which takes a different request body.
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body
The pending identity provider link Id.
The Id of the User that is being linked to the identity provider.
{
"pendingIdPLinkId": "elY3lKxvCQvsH_kfEMmBNLIl6TmydtCrNjHpFgVdxb8",
"userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
}
Response
Response CodesCode | Description |
---|---|
200 | The request was successful. The response will contain a JSON body. |
400 | The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
504 | One or more Webhook endpoints returned an invalid response or were unreachable. Based on the transaction configuration for this event your action cannot be completed. A stack trace is provided and logged in the FusionAuth log files. |
Response Body
A optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.
Please note, that this value will always be overwritten during login to reflect the most current information from the identity provider. In most cases this value will be an email address or username.
The unique Id of the identity provider.
The name of the identity provider.
The type of the identity provider.
The Id for the User that is provided by the identity provider.
The instant the Link was created.
The last instant of the User’s most recent login to the identity provider linked Application.
The Id of the Tenant that this User belongs to.
The token returned from the identity provider. This is treated as an opaque token as the type varies by identity provider, this value may not be returned by all identity providers. When provided, this token is typically a long lived access or refresh token, but consult individual identity provider documentation for specifics.
The unique Id of the FusionAuth User that is linked to the identity provider.
{
"identityProviderLink": {
"displayName": "richard@piedpiper.com",
"identityProviderId": "f50dbb83-4cc2-4e5e-aece-9efe068bddd9",
"identityProviderName": "My OpenIDConnect Identity Provider",
"identityProviderType": "OpenIDConnect",
"identityProviderUserId": "42",
"insertInstant": 1623183147998,
"lastLoginInstant": 1623183152224,
"tenantId": "30663132-6464-6665-3032-326466613934",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
}
}
Retrieve a Link
This API is used to retrieve a single Link, all Links for a specific identity provider and user, or all Links for a user.
Request
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Parameters
The unique Id of the identity provider.
The unique user Id in the 3rd party identity provider. Ideally this value never change and will always uniquely identify the user in the 3rd party identity provider.
The FusionAuth User Id that is linked to the identity provider. When this value is provided, a 404
status code will be returned if the link does not exist, or the link exists but is linked to a different userId
. If you wish to identify if any user is linked, omit this parameter.
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Parameters
The unique Id of the identity provider.
The FusionAuth User Id that is linked to the identity provider.
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Parameters
The FusionAuth User Id that is linked to the identity provider.
Response
Code | Description |
---|---|
200 | The request was successful. The response will contain a JSON body. |
400 | The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 | The object you requested doesn't exist. The response will be empty. |
500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
Response Body
The response body for this API contains either a single Link or an array of Links. When you call this API with identityProviderId , identityProviderUserId , and optionally the userId , the response will contain a single Link. When you call this API with userId and either identityProviderId or identityProviderUserId , the response will contain an array of Links. All response types are defined below along with an example JSON response.
A optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.
Please note, that this value will always be overwritten during login to reflect the most current information from the identity provider. In most cases this value will be an email address or username.
The unique Id of the identity provider.
The name of the identity provider.
The type of the identity provider.
The unique user Id in the third party identity provider. Ideally this value never changes and will always uniquely identify the user in the third party identity provider.
The instant that the Link was created.
The instant when the User logged in last with this identity provider using this link.
The Id of the Tenant that this User belongs to.
The token returned from the identity provider. This is treated as an opaque token as the type varies by identity provider, this value may not be returned by all identity providers. When provided, this token is typically a long lived access or refresh token, but consult individual identity provider documentation for specifics.
Note:
Prior to version 1.28.0
, this value can be retrieved using the User Registration APIs using the registration.token field.
The FusionAuth User Id that is linked to the identity provider.
{
"identityProviderLink": {
"displayName": "richard@piedpiper.com",
"identityProviderId": "f50dbb83-4cc2-4e5e-aece-9efe068bddd9",
"identityProviderName": "My OpenIDConnect Identity Provider",
"identityProviderType": "OpenIDConnect",
"identityProviderUserId": "42",
"insertInstant": 1623183147998,
"lastLoginInstant": 1623183152224,
"tenantId": "30663132-6464-6665-3032-326466613934",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
}
}
Response Body
The list of Link objects.
A optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.
Please note, that this value will always be overwritten during login to reflect the most current information from the identity provider. In most cases this value will be an email address or username.
The unique Id of the identity provider.
The name of the identity provider.
The type of the identity provider.
The unique user Id in the third party identity provider. Ideally this value never changes and will always uniquely identify the user in the third party identity provider.
The instant that the Link was created.
The instant when the User logged in last with this identity provider using this link.
The Id of the Tenant that this User belongs to.
The token returned from the identity provider. This is treated as an opaque token as the type varies by identity provider, this value may not be returned by all identity providers. When provided, this token is typically a long lived access or refresh token, but consult individual identity provider documentation for specifics.
Note:
Prior to version 1.28.0
, this value can be retrieved using the User Registration APIs using the registration.token field.
The FusionAuth User Id that is linked to the identity provider.
{
"identityProviderLinks": [
{
"displayName": "richard@piedpiper.com",
"identityProviderId": "f50dbb83-4cc2-4e5e-aece-9efe068bddd9",
"identityProviderName": "My OpenIDConnect Identity Provider",
"identityProviderType": "OpenIDConnect",
"identityProviderUserId": "42",
"insertInstant": 1623183147998,
"lastLoginInstant": 1623183152224,
"tenantId": "30663132-6464-6665-3032-326466613934",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI0MiIsIm5hbWUiOiJSaWNoYXJkIiwiaWF0IjoxNTE2MjM5MDIyfQ.hFtOTx0nZ58YNJlYLI9kV2Tt0Jg1yxdW7Gy-43V4clc",
"userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
},
{
"displayName": "richard@hooli.com",
"identityProviderId": "363ae8d9-dd4d-4473-bdc6-3694f1d0329e",
"identityProviderName": "Another OpenIDConnect Identity Provider",
"identityProviderType": "OpenIDConnect",
"identityProviderUserId": "9821123",
"insertInstant": 1623183147998,
"lastLoginInstant": 1623183152225,
"tenantId": "30663132-6464-6665-3032-326466613934",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI5ODIxMTIzIiwibmFtZSI6IlJpY2hhcmQiLCJpYXQiOjE1MTYyMzkwMjJ9.bGRRUQBhdg6kS4sjiWrR-7xrOa6A2MzI9QhWlDcNf-Y",
"userId": "fbf0e652-b2b5-45eb-b9c9-d4640889740b"
}
]
}
Retrieve a Pending Link
This API has been available since 1.46.0
This API is used to retrieve a pending IdP Link. A pending IdP Link is created after a user completes login with an Identity Provider configured with a linking strategy of Create a Pending Link . This pending IdP link is then used to link a user in a 3rd party identity provider to a user in FusionAuth.
Retrieving this link may be useful if you are building your own login pages, and need to identify the Identity Provider or various meta-data associated with his pending link.
Request
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Parameters
The unique pending IdP Link Id.
The optional User Id that you intend to link using this pending IdP Link. When provided the user’s current link count will be returned in the response body.
This can be useful if you are limiting the number of links a user may have to a single identity provider. This will help you understand if the link will succeed for this user.
Response
Code | Description |
---|---|
200 | The request was successful. The response will contain a JSON body. |
400 | The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 | The object you requested doesn't exist. The response will be empty. |
500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
Response Body
The tenant configuration for identity provider linking. If enabled the maximumLinks value will be enforced during linking. This will only be present if you have configured a tenant policy for this identity provider.
The maximum number of links a user can have to a single identity provider. This will only be present if you have configured a tenant policy for this identity provider.
The user’s current link count. This will only be present if a userId was provided on the request.
A optional human readable name for this link such as an email address, username or given name. This value should be used to make it easier to identify the user this link represents in the remote identity provider.
The optional email address provided by the identity provider. This value will not always be present, it will depend upon the identity provider.
The unique Id of the identity provider.
The name of the identity provider.
The type of the identity provider.
The unique user Id in the 3rd party identity provider. Ideally this value never changes and will always uniquely identify the user in the 3rd party identity provider.
The optional username provided by the identity provider. This value will not always be present, it will depend upon the identity provider.
{
"identityProviderTenantConfiguration": {
"limitUserLinkCount": {
"enabled": false,
"maximumLinks": 2
}
},
"linkCount": 0,
"pendingIdPLink": {
"displayName": "richard@piedpiper.com",
"email": "richard@piedpiper.com",
"identityProviderId": "af53ab21-34c3-468a-8ba2-ecb3905f67f2",
"identityProviderName": "Xbox",
"identityProviderType": "Xbox",
"identityProviderUserId": "42",
"username": "richard"
}
}
Unlink a User
This API is used to remove a link between a FusionAuth User and a 3rd party identity provider.
Request
Request Headers
The unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon the request parameters or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Parameters
The unique Id of the identity provider.
The Id for the user that is provided by the upstream identity provider. This is the value that will allow FusionAuth to link this user on future logins. This value is expected to be immutable.
The FusionAuth User Id that is linked to the identity provider.
Response
This API does not return a JSON response body.
Code | Description |
---|---|
200 | The request was successful. The response will contain a JSON body. |
400 | The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication. |
404 | The object you requested doesn't exist. The response will be empty. |
500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |