fix(gotrue): ask the server to skip its redirect when linking an identity - #379
Open
yzxcj797 wants to merge 1 commit into
Open
fix(gotrue): ask the server to skip its redirect when linking an identity#379yzxcj797 wants to merge 1 commit into
yzxcj797 wants to merge 1 commit into
Conversation
…tity LinkIdentity issues its GET to /user/identities/authorize without skip_http_redirect, so the server responds with a redirect to the provider's sign-in page. The browser follows it without the Authorization header and the request fails with 'No API key found in request' (supabase-community#378). auth-js' linkIdentity sets skip_http_redirect for exactly this reason; add the query parameter so the response returns the provider URL for the client to navigate to instead. Fixes supabase-community#378
Contributor
|
diagnosis in #378 looks right, but i pulled the branch and ran the tests locally, three things
request side is handled, response side is still open |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #378.
Root cause
Api.LinkIdentityissues itsGET /user/identities/authorizewithoutskip_http_redirect. The server responds with a redirect to the provider's sign-in page; the browser follows the redirect without theAuthorizationheader, and the request then fails with:auth-js'
linkIdentitysetsskip_http_redirectfor exactly this reason — with it, the server returns the provider URL in the response body for the client to navigate to, instead of redirecting (the same shape this SDK's ownsignInWithSSOalready relies on, see itsskip_http_redirectbody parameter).Fix
Add
skip_http_redirect=trueto the query on the LinkIdentity request, matching auth-js. The returnedProviderAuthState(whose URI the caller navigates to) is unchanged.Test
Added
LinkIdentityRequest_ShouldCarrySkipHttpRedirect_GivenAnyProviderto the wire-shape approval tests (IdentityLinkApprovalTests): asserts the emitted request hits/user/identities/authorizewithskip_http_redirect=true, using the fixture's newEmittedRequestaccessor alongside the existingEmittedRequestBody.Note: no .NET SDK on this machine — the change follows the file's existing patterns exactly (
Helpers.AddQueryParamsis already used the same way elsewhere) and CI runs the suite.