Skip to main content
Link OAuth Provider
Initiates an OAuth 2.0 flow to link an additional provider to the currently authenticated user’s account. Requires a valid access token. The flow and callback behavior are identical to the Authorize OAuth endpoint. The authenticated user’s ID is taken from the access token — it cannot be specified in the request body.

Headers

string
required
Bearer {accessToken} — a valid access token for the user linking the provider.

Body Parameters

string
required
The OAuth provider to link. Must be one of: "google", "github", "apple", "facebook".
string
required
The URL to redirect the user to after authorization. Must be a valid URL and must be in the provider’s configured allowed redirect URIs.

Response

string
The URL to send the user’s browser to. It is a one-time Sublay URL; it expires after 10 minutes if it isn’t opened. Once opened, the user has 10 minutes for each step, and at most 30 minutes from this call.
Before going to the provider, Sublay shows the user a page naming the account the provider will be connected to (its verified email, or else its username), with Continue and Cancel. Continue goes on to the provider; Cancel returns to redirectAfterAuth with error=access_denied. The page only works in the browser that opened authorizationUrl, where it can be reloaded; anywhere else it shows that the link has expired, and so does an older link page once a newer one was opened in the same browser. The page is in English.
Open authorizationUrl as-is, in the browser (or auth session) that should end up signed in. It points to Sublay first, which ties the sign-in to that browser and then sends it on to the provider. A sign-in that returns to a different browser is refused with error=state_mismatch, and so is the older of two sign-ins started at the same time in one browser (in any app that uses Sublay). An Apple sign-in doesn’t affect one with another provider, or the other way round.

Callback

After the user authorizes with the provider, they are redirected to redirectAfterAuth with one of: On success — Tokens in the URL fragment (new tokens are issued for the linked account):
On error — Error details in query parameters:
When the project requires email verification before sign-in (Dashboard → Settings → SDK), an account whose email isn’t confirmed can only link a provider whose verified email is the same as the account’s; any other provider is refused with error=link_needs_confirmed_email (“Confirm your email before connecting a sign-in that uses a different email.”) and nothing is linked.

Error Responses

The access token is still valid, but its session no longer exists (signed out, password reset, or the account was claimed by a provider sign-in after its email went unverified). Adding a provider needs a live session, so sign in again.

See Also