Skip to main content
Add the profile scope and the token response tells you who the user is: their account ID, verified email, and name. You can use that to create an account in your product and log them in, the way you would with any other sign-in provider. The flow is the one in Connect a user’s account or, for apps on a device, CLI, desktop, and mobile apps. Only the scope and what you do with the response change.

Pick a mode

Sign-in only

Request profile alone. The consent screen says your product receives the user’s name, verified email, and account ID, and that it cannot use their credits. The token response carries the user object.
In your callback, after the code exchange, find or create your user and start a new session.
  • Start a new session at login. req.session.regenerate replaces the session the visitor had before they signed in, so a session ID planted earlier is useless.
  • Key your user on user.id. It stays the same if the person changes their email.
  • email is always verified. name is omitted when the account has none.
  • organization_id is the workspace the person picked. Use it if your product groups people by team.
  • You don’t have to keep the tokens. For sign-in only, read user and discard them. Your own session keeps the person logged in.
Signing in again reuses the person’s existing sign-in connection to your app. It does not create a new one each time. The person sees the consent screen on every sign-in.

Sign in and use the API

Request profile together with the API scopes you need, for example profile data:execute. The consent screen lists both, and names the workspace that pays. Handle the response in two parts:
  1. Log the person in with user, as above.
  2. Store the tokens and call the API with them, as in Connect a user’s account. Each refresh response includes user again.

Sign in first, connect later

You can ask for profile at login and for API access only when a person first uses a feature that needs it. Send them through the flow again with the API scope, such as data:execute, and store the tokens from that second flow for API calls. The two approvals are separate connections. A token can do exactly what its own consent screen listed, so the sign-in token never gains API access, and a later sign-in that asks only for profile does not affect the API connection. The user sees both on their Connected apps page and can disconnect either one.

Sign out and disconnect

These are different actions. If a person changes the email on their Context.dev account, stored refresh tokens stop working until they sign in again. Their user.id is unchanged, so they land in the same account in your product, and user.email is their new address.