Skip to content
LogoLogo

How to authenticate with OAuth

This guide shows you how to sign a user in through Google.

1. Get the authorization URL

mutation {
  oauthAuthorize(input: {
    provider: GOOGLE
    redirectUrl: "https://app.example.com/auth/callback"
    scopes: ["openid", "email", "profile"]
  }) {
    url
  }
}

2. Send the user to that URL

Google authenticates the user and sends them back with a code parameter.

3. Exchange the code

mutation {
  oauthCallback(input: { provider: GOOGLE, code: "auth-code-from-google" }) {
    session { accessToken refreshToken expiresAt }
  }
}