hps-plugin-auth-github
By Hyperse
hps-plugin-auth-github is a Auth Github plugin in the Hub Auth group.hps-plugin-auth-github provides Auth Github plugin capabilities for Hub Auth. Authentication, identity, and account access integrations. It is especially useful for auth, core workflows.
CoreVendure Plugins
Specifications
Technical details and package information for this product.
Package
@hyperse-hub/hps-plugin-auth-github
Support languages
TypeScript, JavaScript, Prolog, Shell, CSS
Last published
July 02, 2026
@hyperse-hub/hps-plugin-auth-github
GitHub OAuth authentication for Vendure Shop API.
Features
- GitHub OAuth sign-in / sign-up: uses Vendure
authenticate + github strategy (creates a Customer/User if not exists)
- Avatar sync: downloads GitHub
avatar_url as a Vendure Asset and stores it in Customer.customFields.avatar
- Cross-strategy email conflict protection (optional): prevents the same email being used across different auth strategies
- Set native password: provides Shop GraphQL
setGithubPassword(email, password) to add a native auth method after GitHub login
Install
yarn add @hyperse-hub/hps-plugin-auth-github
Vendure configuration
Register the plugin in vendure-config.ts and configure GitHub OAuth credentials:
Options
- githubClientId: GitHub OAuth Client ID
- githubClientSecret: Client secret
- preventCrossStrategies: enforce unique email across all Shop auth strategies (default
false)
- If enabled, the login will be rejected when the GitHub email is already used by another strategy
Note: the strategy is only added to config.authOptions.shopAuthenticationStrategy when githubClientId is non-empty.
GitHub provider setup (OAuth App)
Create a GitHub OAuth App and configure:
- Authorization callback URL: your frontend callback URL (frontend exchanges the
code via Shop API)
- Scopes: recommend at least
read:user and user:email
- The plugin uses
/user.email if present; otherwise it calls /user/emails to find a primary + verified email (requires user:email)
Shop API usage
1) Obtain the GitHub code in your frontend
Redirect the user to GitHub authorization. After the callback, your frontend receives the code (and optional state).
2) Call Vendure authenticate (strategy: github)
Send code (and optional state) to Vendure authenticate. In most Vendure setups, the Shop API exposes a field named github under the authenticate input:
Note: the input type is defined by the strategy defineInputType() (GithubAuthInput: code + optional state). If your Shop API schema differs, follow your schema; the key is using the github strategy with { code, state? }.
3) (Optional) Set a native password: setGithubPassword
After the user signs in with GitHub (must be authenticated), you can call:
- This mutation requires authentication (
Permission.Authenticated)
- It adds a native authentication method to the current user, enabling email+password login
email must match the current user's identifier, otherwise it throws Unauthorized
Data model change: Customer.customFields.avatar
The plugin ensures Customer.customFields.avatar exists (relation to Asset) on bootstrap:
- Field name:
avatar
- Type: relation ->
Asset
- Readonly:
readonly: true
When a user is created via GitHub for the first time, the plugin tries to download the avatar and store it in this field.
FAQ
Why is there no email after login?
Some GitHub accounts don't expose an email via /user. The plugin will call /user/emails to find a verified email, which requires the user:email scope.
What does preventCrossStrategies check?
It checks whether the GitHub-provided email is already associated with a user via any other Shop auth strategy. If so, it rejects the GitHub login to avoid one email being used across multiple strategies.
import { HpsPluginAuthGithub } from '@hyperse-hub/hps-plugin-auth-github';
export const config = {
plugins: [
HpsPluginAuthGithub.init({
githubClientId: process.env.GITHUB_CLIENT_ID ?? '',
githubClientSecret: process.env.GITHUB_CLIENT_SECRET ?? '',
preventCrossStrategies: false,
}),
],
};
mutation AuthenticateWithGithub($code: String!, $state: String) {
authenticate(input: { github: { code: $code, state: $state } }) {
... on CurrentUser {
identifier
}
... on InvalidCredentialsError {
errorCode
message
authenticationError
}
}
}
mutation SetGithubPassword($email: String!, $password: String!) {
setGithubPassword(email: $email, password: $password) {
id
identifier
}
}