createExternalAccount

Adds an external account for the user. A new ExternalAccount will be created and associated with the user. This method is useful if you want to allow an already signed-in user to connect their account with an external provider, such as Facebook, GitHub, etc., so that they can sign in with that provider in the future.

Note: The social provider that you want to connect to must be enabled in your app's settings in the Clerk Dashboard. See: (Social connections)https://clerk.com/docs/authentication/configuration/sign-up-sign-in-options#social-connections-o-auth

After calling createExternalAccount, the initial state of the returned ExternalAccount will be unverified. To initiate the connection with the external provider, redirect the user to the com.clerk.network.model.verification.Verification.externalVerificationRedirectUrl contained in the result of the createExternalAccount call.

Upon return, inspect within the user.externalAccounts the entry that corresponds to the requested strategy:

  • If the connection succeeded, then externalAccount.verification.status will be verified.

  • If the connection failed, then the externalAccount.verification.status will not be verified and the externalAccount.verification.error will contain the error encountered, which you can present to the user. To learn more about the properties available on verification, see the verification reference.