Remove the Fragment From a GitHub OAuth Redirect URI and Verify Sign-In

Move a GitHub OAuth redirect URI to a fragment-free HTTPS callback, verify state and token exchange, and return the signed-in user to integration settings.

GitHub OAuth redirect URI illustrated as a URL with its old fragment detached, three matching callback values and a separate settings destination after state validation and exchange.GitHub OAuth redirect URI illustrated as a URL with its old fragment detached, three matching callback values and a separate settings destination after state validation and exchange.
In the illustrative staging flow, the registration, authorize request and exchange use one callback URI. The app selects the settings page after sign-in. Based on GitHub’s GitHub App callback and user token documentation.

When your GitHub App sends users back to a callback ending in #integrations, deleting the suffix solves only the registration problem. The app still needs to finish sign-in and take the browser to the integrations page. Change the GitHub OAuth redirect URI and the app’s success redirect together. Then check the two handoffs separately so a successful GitHub authorization cannot hide a broken landing page.

This tutorial is for a developer who maintains a GitHub App’s existing browser authorization flow. You need edit access to the staging GitHub App registration, a GitHub test user, and an HTTPS deployment where you can change the callback handler and observe its token client. Start with an app that already creates and validates OAuth state, exchanges codes server-side, and establishes a local session for the verified GitHub user. The example moves one fixed destination into the server’s success path. The endpoint names and parameter behavior come from GitHub’s GitHub App reference. The staging hostname, application behavior and expected observations are illustrative. GitHub App user access tokens

GitHub Changelog announced the change on November 30, 2026. Starting February 1, 2027, GitHub.com will reject authorization requests whose redirect URI contains a fragment and stop allowing fragment-bearing callback registrations. The announcement covers GitHub.com Free, Team and Enterprise Cloud and excludes GitHub Enterprise Server. The migration below also applies to an app that already uses a fragment-free callback but still needs to return users to a specific screen. GitHub Changelog

GitHub Changelog page for the redirect URI fragment deprecation.
GitHub Changelog’s announcement on deprecating redirect URI fragments for OAuth and GitHub Apps. · Original source

Timeline from November 30, 2026, when GitHub announced fragment deprecation, to February 1, 2027, when GitHub.com is scheduled to reject fragment-bearing authorization redirect URIs.Timeline from November 30, 2026, when GitHub announced fragment deprecation, to February 1, 2027, when GitHub.com is scheduled to reject fragment-bearing authorization redirect URIs.
GitHub Changelog announced fragment rejection on November 30, 2026, with enforcement starting February 1, 2027 on GitHub.com. GitHub Enterprise Server is outside the announced change.

Define the callback and the destination

The GitHub callback is where your server receives the authorization response. The destination is where your own server sends the browser once the app has a signed-in session. GitHub needs the callback’s full address. Your handler needs the destination’s local path. Keeping those values separate lets you change the application’s landing page without asking GitHub to accept a different callback.

  1. Write down the old registration for task:github-callback-01. It is https://staging.example.com/oauth/github/callback#integrations. The browser handles #integrations locally. A server handling the callback request sees the path and incoming query, so a server-side route cannot select behavior by reading that fragment from the request.
  2. Use https://staging.example.com/oauth/github/callback as the new callback value. Route the HTTP GET for /oauth/github/callback to the existing OAuth completion logic. If the same path formerly rendered a frontend page, update the route so the server handles the authorization response there before any frontend fallback can serve it.
  3. Set the successful session destination to /settings/integrations. Return that literal path in the success redirect. The application already knows which screen belongs to this flow, so it can choose the path from server configuration without accepting a destination supplied by the browser.
  4. Open the settings page as the signed-in test user before making the change. Confirm that /settings/integrations is a real route and note one page element that identifies the authenticated view in your app. In this illustrative case that element is the GitHub integration panel. You will check the same thing after a fresh sign-in.

A callback that accepts a destination from the query would introduce another input to validate at the point where the app handles a code. A fixed local path avoids that decision for this case. Keep state dedicated to binding the callback to the initiating browser session. If your app uses the same provider sign-in for several screens, choose the correct destination on the server when starting the transaction and retrieve it from that transaction after validation. The fixed destination in this tutorial needs no routing data in state itself. RFC 6749 covers fragment-free redirection endpoints, state binding and the risk of open redirectors. RFC 6749

Before touching the registration, identify the three places where the callback address is actually set. One is in GitHub. A second is in the code or library configuration that builds the browser’s authorize request. The third is in the server’s code-exchange configuration. If the application derives one of the latter two from the incoming request, switch it to the trusted configured value used by the sign-in starter. The incoming callback has transient query fields, and a reverse proxy can also make the application’s internal hostname differ from its public HTTPS origin. Both are reasons to use the selected public URI verbatim.

Wire one callback value through both requests

Use the following filled worksheet as the staging change and acceptance record. staging.example.com identifies the illustrative environment. For a real run, use your staging origin consistently throughout the worksheet. The values under Expected result describe what to verify in that environment.

Input Action Expected result
task:github-callback-01 registration currently ends in /oauth/github/callback#integrations Save https://staging.example.com/oauth/github/callback in the staging GitHub App’s Callback URL field with wildcard matching disabled for that URL. Reopening the settings shows the exact HTTPS URL without a fragment.
task:github-callback-01 sign-in starts from the staging app Send redirect_uri=https://staging.example.com/oauth/github/callback as the decoded parameter value on GET https://github.com/login/oauth/authorize, along with the staging client ID and fresh state. Preserve the existing PKCE challenge parameters. The test browser returns to /oauth/github/callback after authorization. The handler receives the query fields code and state.
task:github-callback-01 callback has the expected state for its pending session and one code Validate state first. Keep the callback URI associated with this attempt and send it as the redirect_uri on the server’s POST https://github.com/login/oauth/access_token. Use the original PKCE verifier when a challenge was sent. State validation succeeds before the exchange starts. The exchange uses the same decoded URI as the authorize request. The existing client recognizes a successful user access token response.
task:github-callback-01 handler test with fixture code fixture-code, one pending session, and absent or different state Invoke the handler through the app’s own tests with a recording token-client stub. Run one case with state omitted and another with returned state fixture-other and stored state fixture-expected. Both calls produce the application’s failure response. The token-client stub has zero calls and the handler sends no success redirect.
task:github-callback-01 exchange succeeds and the app has verified the test user and set the session Respond with a redirect whose Location is /settings/integrations. Open the landing page and check that the same signed-in session can reload it. The final browser URL is https://staging.example.com/settings/integrations, with an empty query and fragment. The test user sees the GitHub integration panel.

The table’s authorization and exchange rows describe the parameter value before serialization. On the wire, the authorize URL has an encoded query. Encoding belongs in the request builder. Put the plain HTTPS string into the library’s parameter map and let its serializer do the work. If you paste a pre-encoded URL into a builder that encodes it again, the decoded value GitHub receives can still contain escape sequences. Compare the decoded value with the registration, including any trailing slash.

In GitHub, open the settings for the account or organization that owns the staging app. Go to Developer settings, then GitHub Apps, and choose Edit for the intended registration. Use the Callback URL field in the user authorization settings. Read back the saved value before you try sign-in. Apps can have multiple callbacks, and GitHub uses the first one when redirect_uri is absent. Explicit selection makes the test independent of list order. With wildcard matching disabled, GitHub documents an exact match. Modifying a GitHub App registration · Callback URL matching

Prepare the server route and its missing-state behavior before relying on the new registration. For a staging deployment where nobody else depends on sign-in, pause new attempts during the coordinated change, save the callback, deploy or activate the matching request configuration, then start a fresh attempt. If the old and new code paths are rolled out separately, verify which build served the authorization start and the callback. A deployment can update the frontend sign-in link while an older backend worker still supplies the old URI for exchange.

During the exchange, keep the staging client ID and client secret in the existing server-side OAuth client. Supply the returned code and the same URI that the app supplied at authorization. When the app sent a PKCE challenge, GitHub requires the original verifier, which belongs to that pending attempt. Building a new verifier on the callback would break the exchange even if every URL matched. GitHub’s reference documents its endpoint inputs, and RFC 6749 section 4.1.3 specifies identical redirect URI values when the URI was included at authorization. GitHub App user access tokens · RFC 6749

Decision diagram for a GitHub App callback showing an invalid-state stop before token exchange and a valid-state path that reaches the fixed integrations page after exchange and session success.Decision diagram for a GitHub App callback showing an invalid-state stop before token exchange and a valid-state path that reaches the fixed integrations page after exchange and session success.
The illustrative handler rejects missing or mismatched state before token exchange. After a valid exchange and session setup, it sends the browser to the settings page. Based on GitHub’s user access token documentation and RFC 6749.

Follow a fresh sign-in through to the settings page

  1. Open a fresh browser session for the staging app and use its normal GitHub sign-in entry point. Start from the app so that it creates the pending transaction. Sign in as the intended test user and complete GitHub’s prompts if shown. The presence or absence of a prompt does not establish whether your callback worked.
  2. Check the browser’s request to GitHub. Confirm that the decoded redirect_uri is exactly https://staging.example.com/oauth/github/callback and that the request carries a state parameter. Inspect names and the configured URL locally. Keep live code, state and cookies out of saved traces and screenshots.
  3. Check the browser’s return to the staging origin and the server’s handler outcome. The browser should request GET /oauth/github/callback with code and state. The callback should be handled by the OAuth endpoint, even if your app also has a frontend fallback for unknown paths. Look for a sanitized handler event or assertion showing that the pending state matched before exchange.
  4. Check the server-side exchange separately. Use the token client’s outcome and a safe record of the configured redirect URI. A browser trace shows the return to your handler and its next response. The backend exchange takes place outside that browser connection. For this test you need only the endpoint, the URI value and whether the app recognized exchange success. Keep the payload and token response out of the record.
  5. Confirm the application verified the GitHub user through its existing identity lookup and completed its session handling. Then check the handler’s success response and the address bar. Expect Location to contain /settings/integrations and the final URL to contain neither the authorization code nor the returned state. Reload the destination and confirm the integration panel is still available to the expected test user.

A final page with the right heading can give a misleading pass if you start with an existing signed-in session. A fresh session forces the app to prove it can perform the callback and establish the session before loading the page. Likewise, a token-client success event can coexist with a session cookie that the next browser request never sends. If the app sends the expected redirect but the browser immediately goes back to sign-in, examine whether the callback response set the session and whether the follow-up request retained it. Compare those observations with a working staging login, keeping raw cookie values out of your notes. For a separate browser check that starts from deliberately saved state, see Playwright MCP Authentication.

The successful callback should finish as a redirect response without serving the ordinary integrations page at the callback URL. RFC 6749 recommends extracting the authorization credentials and redirecting again to an endpoint that does not expose them. In the example, the clean page URL comes from the literal destination path. Logging policies for the earlier callback request need to protect its query separately. RFC 6749

Prove the handler stops before exchange

Use your application’s handler tests with a recording stub wherever the handler normally calls the token client. Run this pair against the changed server route. The fake code and state values are test inputs that never leave the test process. Give each case a fresh in-memory transaction so an earlier refusal cannot make the second assertion pass by exhausting shared test state.

  1. For the missing-state case, seed a pending transaction whose expected state is fixture-expected. Call GET /oauth/github/callback?code=fixture-code through the test router with that session attached. Assert that the application’s invalid sign-in branch ran, that the fake client recorded zero token exchanges, and that the response did not redirect to /settings/integrations.
  2. For the mismatched-state case, seed an independent transaction with the same fixture expectation. Call GET /oauth/github/callback?code=fixture-code&state=fixture-other with its session. Make the same three assertions. The presence of a code and a syntactically present state should still leave the token-client call count at zero.
  3. Check that the stub records calls by running a positive control in the same harness. Seed another transaction, supply state=fixture-expected, and configure the stub to return the application’s normal successful token result. Stub the identity lookup for the fixture user as well. Expect the callback to invoke the token client once and return /settings/integrations after the session logic succeeds.

The positive control catches a misleading failure test. A request sent to an unmounted route could produce a rejection and zero exchanges without exercising state validation. Assert the handler’s specific rejection outcome, using your app’s existing error branch or a sanitized event, and check that the router dispatches the positive control to the same handler. A real sign-in complements this check by testing that a browser returns with the same transaction available. If the live run rejects a state that appears to have returned, compare whether the session created at authorize time is available on the callback host and whether the app can recover the pending transaction.

RFC 6749 section 10.12 requires cross-site request forgery protection at the redirection endpoint and describes using state to verify the callback against the initiating browser’s session. GitHub’s GitHub App web-flow reference explicitly says to abort the flow if the returned state differs from the value sent. In this example, the handler expects a state value on every successful callback, so an omitted value also takes the failure branch before exchange. RFC 6749 · GitHub App user access tokens

The recording stub proves a boundary that a browser error page alone cannot establish. Keep the ordered outcomes in a trace with sensitive fields removed if you need to hand the check to another operator. The same evidence principle applies when an automation performs the browser check and somebody else reviews it. You Can’t Replay What You Can’t See · Write a Finish Line the Transcript Can Prove

Locate the failure by the last successful step

What you see in staging What to check next
GitHub reports a redirect URI mismatch before the browser reaches staging. Read the actual staging GitHub App registration for the client ID in the request. Compare the decoded redirect_uri against the exact saved value. Check the scheme, host, port, path and trailing slash.
The browser requests the staging callback but sees a 404 or the generic frontend shell. Check the HTTPS ingress and GET route mapping for /oauth/github/callback. Compare the proxy’s upstream path and the deployed router’s path. Verify the OAuth handler owns the route.
The handler runs but records a state rejection. Trace the local pending session from sign-in start to callback. Check the callback’s session binding and the transaction lookup before touching the token client.
State passes but the exchange returns an error. Compare the sent URI with both the saved registration and the URI captured for this attempt. Check whether the code belongs to a fresh attempt, the client credentials belong to the same staging app, and the original verifier is present if the request used PKCE.
The exchange and identity lookup succeed, but the browser lands on the wrong page or loops. Read the callback’s success Location, then follow any subsequent redirects. Check session availability on the settings request and verify the configured destination resolves on the staging host.

GitHub documents redirect_uri_mismatch for a URI that fails to match the GitHub App registration. Keep the error with the stage that produced it. When the browser reaches the correct staging path and receives a staging response, you already have evidence that this request crossed the authorization-to-callback boundary. Investigate the proxy or router for a staging 404, and the pending session for a state rejection. When GitHub displays the mismatch and the request never reaches staging, start with the registration and the authorize request. GitHub App user access tokens

If the staging app also authorizes users during installation, check that entry point as its own flow. GitHub’s reference says the install-triggered path uses the first callback in the registration. The browser-started example here supplies redirect_uri explicitly. A passing browser sign-in can therefore coexist with an installation path that still depends on a different entry in the callback list. The GitHub App setup URL is a separate setting for post-installation routing. For work that runs under a GitHub App installation identity, see Copilot Seat Management API With an Enterprise GitHub App. GitHub App user access tokens · Callback URL matching

Recover on the same fragment-free route

A workable rollback for this case restores the OAuth completion code while keeping the public callback address usable. Prepare a recovery build by mounting the previously working server-side completion logic at /oauth/github/callback and wiring it to the fixed settings destination. Verify that build with the same fragment-free configuration before using it as the recovery point. If the old release depended on frontend fragment routing, prepare and verify a recovery build with the server-side route before the cutover.

  1. Keep the verified recovery build and the exact staging configuration together. Its registration, authorize value and exchange value are all https://staging.example.com/oauth/github/callback. Its success Location is /settings/integrations.
  2. Rehearse restoring that build in staging. Pause new sign-in starts while changing the active handler or settings. Restore the matching configuration values and read back the GitHub registration. If the URI is already correct, leave it in place and restore the handler and request configuration.
  3. Start a new browser authorization after the restore. An earlier attempt can carry state, a verifier or a URI associated with the previous build, and OAuth authorization codes are single-use. Ask the test user to start from the app’s sign-in entry point again if a pre-change attempt fails during the rehearsal. RFC 6749
  4. Require the fresh positive trace and the two local state refusals on the restored build. The recovery is complete when a fresh attempt reaches the handler, matches state, exchanges the code and opens the authenticated settings page with a clean URL. Record which build handled those checks, alongside the three callback values and the final path.

Keeping a verified recovery build gives you a way to correct application behavior without depending on GitHub accepting the old fragment registration. It also gives the next maintainer a known set of values to compare if a later deploy breaks sign-in. For repository changes that need another person to review the observable behavior before merge, see AI PR Review Agent Policy.

Sources

  1. GitHub Changelog — Deprecating redirect URI fragments for OAuth and GitHub Apps
  2. GitHub Docs — About the user authorization callback URL
  3. GitHub Docs — Modifying a GitHub App registration
  4. IETF — RFC 6749, The OAuth 2.0 Authorization Framework
  5. GitHub Docs — Generating a user access token for a GitHub App
YOU'RE THROUGH THIS ONE.

Keep connecting the dots.

Back to the library

Many assistants.
One place to remember.

Bring your AI sessions, context, and usage together with Automater.

Meet Automater