Link social identity to user

POST /api/users/{userId}/identities

Link authenticated user identity from a social platform to a Logto user.

The usage of this API is usually coupled with POST /connectors/:connectorId/authorization-uri. With the help of these pair of APIs, you can implement a user profile page with the link social account feature in your application.

Note: Currently due to technical limitations, this API does not support the following connectors that rely on Logto interaction session: @logto/connector-apple, @logto/connector-saml, @logto/connector-oidc and @logto/connector-oauth.

Path parameters

  • userId string Required

    The unique identifier of the user.

application/json

Body Required

  • connectorId string Required

    The Logto connector ID.

  • connectorData object Required

    A json object constructed from the url query params returned by the social platform. Typically it contains code, state and redirectUri fields.

Responses

  • 200 application/json

    A new identity is linked to the user.

    Hide response attribute Show response attribute object
    • * object Additional properties

      Additional properties are allowed.

      Hide * attributes Show * attributes object
  • Bad Request

  • Unauthorized

  • Forbidden

  • Not Found

  • Unprocessable Content

POST /api/users/{userId}/identities
curl \
 -X POST https://[tenant_id].logto.app/api/users/{userId}/identities \
 -H "Authorization: Bearer $ACCESS_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{"connectorId":"string","connectorData":{}}'
Request examples
{
  "connectorId": "string",
  "connectorData": {}
}
Response examples (200)
{
  "additionalProperty1": {
    "userId": "string",
    "details": {}
  },
  "additionalProperty2": {
    "userId": "string",
    "details": {}
  }
}