Acesso Comercial / Docs / Storefront / API
Ctrl K
MUTATION

clientGoogleLogin

Autenticação via Google OAuth. Recebe o token do Google e autentica ou cria o cliente automaticamente.

Input

ClientGoogleLoginMutationInput!

CampoTipoDescrição
hostnameString!Hostname da loja.
tokenString!Token OAuth do Google (id_token do Google Sign-In).

Retorno

CampoTipoDescrição
tokenStringToken de autenticação.
userAuthUserDados do usuário autenticado.
Também disponível: clientGoogleSignup com os mesmos inputs — cria conta caso o e-mail não exista.

Mutation

GraphQL
mutation GoogleLogin($input: ClientGoogleLoginMutationInput!) {
  clientGoogleLogin(input: $input) {
    token
    user {
      id
      name
      email
    }
  }
}

Variables

JSON
{
  "input": {
    "hostname": "minha-loja",
    "token": "eyJhbGciOiJSUzI1NiIs..."
  }
}

Resposta

JSON
{
  "data": {
    "clientGoogleLogin": {
      "token": "eyJhbGciOiJIUzI...",
      "user": {
        "id": "user789",
        "name": "João Google",
        "email": "joao@gmail.com"
      }
    }
  }
}

Fetch

JavaScript
const response = await fetch('/graphql', {
  method: 'POST',
  credentials: 'include',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    query: `mutation($input: ClientGoogleLoginInput!) {
      clientGoogleLogin(input: $input) { user { id name email } }
    }`,
    variables: { input: { hostname: "minha-loja", googleToken: "ya29..." } }
  })
});

cURL

Bash
curl -X POST https://minha-loja.com/graphql \
  -H "Content-Type: application/json" \
  -d '{"query":"mutation { clientGoogleLogin(input: { hostname: \"minha-loja\", googleToken: \"ya29...\" }) { user { id name } } }"}'