[Website] Improve OAuth flow for private GitHub repositories #3181
+35
−6
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.
Motivation for the change, related issues
When using blueprints that reference private GitHub repositories, the OAuth authentication flow has several issues:
Hash blueprints are lost: URL fragments (e.g.,
#{"steps":...}) are not sent to servers in HTTP requests, so they're lost during the OAuth redirect to GitHub and back.Token not used after OAuth: The
createGitAuthHeaders()function captured the OAuth token at creation time, but the token is only available after the OAuth redirect completes. It still works here because the page reloads after OAuth, and the token is acquired before boot starts on the fresh page. The bug would only show when we remove the blueprint parameters as we do inpersonal-wp.startPlaygroundWebthrows an error (e.g.,GitAuthenticationError), the catch block handles it but execution continues to run client setup code, which shouldn't happen for failed boots.Implementation details
Add
buildOAuthRedirectUrl(): Converts URL fragment blueprints toblueprint-urlquery parameters before the OAuth redirect, preserving the blueprint through the round-trip.Fix token capture timing: Move token retrieval inside the returned function so it's captured at call time, not creation time.
Add early return in catch block: Prevent client setup code from running after boot errors.
Testing Instructions (or ideally a Blueprint)