Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

You can let an OpenAI-powered agent work with a user’s GitHub repositories without giving it your OpenAI API key. Keep the OpenAI key on your server, have the user authorize a GitHub App separately, and give the agent only the GitHub access it needs. A server-side credential proxy or OpenAI’s Agents API vault can keep raw credentials out of the agent’s sandbox.

Keep OpenAI and GitHub credentials separate

An OpenAI API key authenticates your application to OpenAI; it does not grant access to GitHub. OpenAI says to treat the key as a secret and not expose it in browser code or other client-side applications. Load it on the backend from an environment variable or a key-management service, and make OpenAI requests from server-side code. OpenAI API authentication

For GitHub actions performed on behalf of a user, use a separate authorization flow. A GitHub App can obtain a user access token after the user consents. The agent or your backend then uses that GitHub grant for permitted repository operations; it never needs the OpenAI key. GitHub App user authorization

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose whose identity should appear on GitHub

Use a user access token when actions should be attributed to the consenting user. Use GitHub App installation authentication when actions should be attributed to the app instead. This choice affects audit and authorship semantics, not just how the token is obtained. GitHub App user authorization

#1 Best Overall
Yubico - Security Key C NFC - Basic Compatibility - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key C NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key C NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key C NFC via USB-C and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

Set up user-authorized GitHub access

  1. Keep the OpenAI key server-side. Read it from a server environment variable or key-management service. Do not put it in browser JavaScript, the agent’s prompt, or tool output. OpenAI API authentication
  2. Create a GitHub App with narrowly scoped permissions. Request only the repository permissions required by the workflow. A user token’s effective access is limited by both the app’s permissions and the user’s own access. GitHub user token guide
  3. Obtain the user’s consent. GitHub documents a web application flow for browser-based applications and a device flow for headless clients or clients without a browser. For a web flow, validate the returned state against the value originally sent and abort if it does not match. GitHub strongly recommends PKCE for the code exchange; for a hosted web application, keep the client secret and token exchange on the server. GitHub user token guide
  4. Limit repository reach when possible. GitHub’s user-token guide documents a repository_id parameter that can restrict a token to one repository the user and app can already access. Confirm access using GitHub’s installation and repository APIs; do not assume that the user can reach every repository associated with an installation. GitHub user token guide
  5. Keep the GitHub grant out of the sandbox. Store the authorization grant securely in your application or, where appropriate, an OpenAI Agents API vault. The vault guide describes OAuth grants using auth.type: "mcp_oauth", with the application handling authorization and consent and able to include expiry and refresh-token configuration. OpenAI Agents API vaults
  6. Use a proxy for sandbox commands. OpenAI documents environment credentials that a proxy injects into requests sent to an allowed host. The sandbox receives a placeholder rather than the raw secret. A placeholder cannot perform local signing or computation; expose those operations through a server-side function tool that keeps the credential on the application side. OpenAI Agents API vaults
  7. Handle expiration and revocation. GitHub documents an eight-hour default lifetime for user access tokens and a six-month lifetime for refresh tokens when expiration is enabled. An authorized app can refresh an access token. Protect both token types, and stop making GitHub requests for a user after authorization is revoked. GitHub user token guide

Understand the access boundary

A GitHub App user token does not grant blanket access to everything the user can see. Effective access is constrained by the intersection of the user’s access, the app’s permissions, and the account where the app is installed. For example, installing the app only on a user’s personal account does not authorize access to an organization repository just because that user belongs to the organization. Each organization member who needs user-attributed actions must authorize the app, and the app must be installed where the target repository resides. GitHub App user authorization GitHub user token guide

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check these details before granting access

  • Actor: Decide whether GitHub activity should be recorded as the user or as the app.
  • Repository and organization scope: Verify installation coverage and the user’s actual access to each target.
  • Permissions: Request only the read and write capabilities the workflow requires.
  • Token lifecycle: Account for token expiry, refresh handling, secure storage, and revocation.
  • Consent experience: Choose a web flow for browser-based apps or a device flow for headless clients.

These are separate decisions: a user’s consent does not override the app’s permissions, installation scope, or the user’s own repository access.

Best Value
FIDO2 U2F Security Key Passkey Two-Factor Authentication (2FA) USB Key PIN+Touch (Non-Biometric) USB-A Type TrustKey T110
  • Security Key : Protect your online accounts against unauthorized access by using FIDO2 and U2F authentication with T110. It's the world's most protective security key that works with windows, Mac OS, Linux as well as Chrome, Firefox, Edge and many other major browsers.
  • Certified with the new FIDO2 standard, T110 provides the benefit of fast login and strong protection against phishing, account takeover as well as many other online attactks.
  • Works with : Bank of America, Github, Google, Microsoft, DUO, Twitter, Facebook, Dropbox, Apple, ebay, BINANCE, mor and more.
  • Fits USB-A port : Insert the T110 security key into the USB-A port of each service and log in conveniently with one touch
  • For the driver download and user guide, please visit TrustKey Solutions Home support page.
Rank #4
Yubico - Security Key NFC - Basic Compatibility - Multi-Factor Authentication (MFA) Key, Connect via USB-A or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key NFC via USB-A and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.
Rank #3
Yubico - YubiKey 5 NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-A or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5 NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5 NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5 NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts
Rank #2
Yubico - YubiKey 5C NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5C NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5C NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5C NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.