DevelopersLogin with CodePinion (OAuth)

Login with CodePinion (OAuth)

Let people sign in to your own app with their CodePinion account, using OAuth 2.0 and OpenID Connect.

Reference3 min read

CodePinion is an OAuth 2.0 and OpenID Connect provider. Your own web app can offer Login with CodePinion the way sites offer sign-in with Google, using any standard OpenID Connect library.

It is for identity only: your app learns who the person is, not access to their CodePinion repositories or data.

Register your app

  1. Open Settings → OAuth Apps (/settings/developer (requires sign-in)) and choose New app.
  2. Give it a name, its redirect URIs, and optionally a homepage and a logo. For the logo, upload a PNG, JPEG, WebP or GIF up to 2 MB, or give the address of an image. An upload is used over an address, and with neither, people see your app's initial.
  3. Copy the client ID and client secret. The secret is shown once; if you lose it, regenerate it, which stops the old one working.

Registering an app under Settings → OAuth Apps.

Rules for redirect URIs:

  • They must use https://. http://localhost and http://127.0.0.1 are allowed for local development.
  • They are matched exactly. No wildcards, prefixes or subdomains.

You can register up to 10 apps. Deleting an app revokes every token it was issued.

Endpoints

Most libraries only need the discovery document; the rest is listed for completeness.

Address
Discoveryhttps://api.codepinion.co.ke/oauth/.well-known/openid-configuration
Issuerhttps://api.codepinion.co.ke/oauth
Authorizehttps://api.codepinion.co.ke/oauth/authorize/
Tokenhttps://api.codepinion.co.ke/oauth/token/
User infohttps://api.codepinion.co.ke/oauth/userinfo/
Revokehttps://api.codepinion.co.ke/oauth/revoke_token/
Signing keys (JWKS)https://api.codepinion.co.ke/oauth/.well-known/jwks.json

The flow

CodePinion supports the authorization code flow with PKCE, which is required for every app, including server-side ones with a secret.

  1. Send the person to the authorize endpoint with your client_id, a registered redirect_uri, response_type=code, the scope, a state, and a PKCE code_challenge (S256).
  2. They sign in to CodePinion if needed, and see a consent screen naming your app and what it asks for.
  3. CodePinion redirects back to you with code and state (or error if they declined).
  4. Your server exchanges the code at the token endpoint, with the code_verifier, for an ID token, an access token and a refresh token.
Exchange the codeShell
curl -X POST https://api.codepinion.co.ke/oauth/token/ \
  -d grant_type=authorization_code \
  -d code="$CODE" \
  -d redirect_uri=https://yourapp.example/callback \
  -d client_id="$CLIENT_ID" \
  -d client_secret="$CLIENT_SECRET" \
  -d code_verifier="$CODE_VERIFIER"

Scopes and claims

ScopeClaims
openidsub: the person's CodePinion user ID. Required.
profilename, picture, preferred_username (their public handle when they have one).
emailemail, and email_verified, which is always true: every CodePinion sign-in proves the address with an emailed code.

Token lifetimes

TokenLasts
Authorization code5 minutes, single use.
Access token1 hour.
ID token1 hour.
Refresh token30 days. Each use returns a new one and retires the old; reusing a retired one is detected.

People see the consent screen the first time they sign in to your app, and again whenever you ask for more scopes than they have already granted. A consent request that isn't answered expires after 10 minutes.

The first time someone authorizes your app, CodePinion emails them, with a link to revoke it. They can see and revoke every app under Connected apps (requires sign-in); revoking removes only their own tokens.