API Reference
OAuth: tokens

Get or refresh a token

POST/token
Base URL: https://google-ads.mimicr.dev · provider: https://oauth2.googleapis.com

Exchanges an authorization code for an access token (grant_type=authorization_code), or refreshes an access token (grant_type=refresh_token). The body is form-encoded.

The response has access_token, expires_in (3599), scope, token_type and, when openid was granted, id_token. refresh_token is returned only when the authorization asked for access_type=offline and the grant is new; the refresh grant returns the same JSON without it. The scope may be a subset of what was requested.

In Mimicr, access tokens last 3599 s on the sandbox clock, and the id_token is an RS256 JWT signed with a sandbox key. Service accounts (jwt-bearer) are not simulated and return unsupported_grant_type.

Authorization

Public route, no token.

Body

application/x-www-form-urlencoded
grant_typestringrequired

As defined in the OAuth 2.0 specification, this field's value must be set to authorization_code to exchange a code, or refresh_token to refresh an access token.

authorization_coderefresh_token
codestring

The authorization code returned from the initial request. Required for authorization_code.

Example: "4/0A…"
redirect_uristring

One of the redirect URIs listed for your project. Required for authorization_code; it must be the one used in the authorization request.

refresh_tokenstring

The refresh token returned from the authorization code exchange. Required for refresh_token.

Example: "1//0…"
client_idstringrequired

The client ID obtained from the API Console.

client_secretstringrequired

The client secret obtained from the API Console.

Example: "GOCSPX-…"

Responses

200Tokens.
access_tokenstringrequired

The token that your application sends to authorize a Google API request.

Example: "ya29.a0…"
expires_inintegerrequired

The remaining lifetime of the access token in seconds.

Example: 3599
refresh_tokenstring

A token that you can use to obtain a new access token. Refresh tokens are valid until the user revokes access. This field is only present if the access_type parameter was set to offline in the initial request to Google's authorization server.

scopestringrequired

The scopes of access granted by the access_token expressed as a list of space-delimited, case-sensitive strings.

token_typestringrequired

The type of token returned. At this time, this field's value is always set to Bearer.

Bearer
id_tokenstring

A JWT that contains identity information about the user. Present when the openid scope was granted.

400invalid_grant (bad, used or expired code; revoked refresh token), redirect_uri_mismatch, invalid_request (missing parameter) or unsupported_grant_type.
errorstringrequired

An OAuth 2.0 error code.

invalid_requestinvalid_clientinvalid_grantredirect_uri_mismatchunsupported_grant_typeinvalid_token
error_descriptionstring

Human-readable text with additional information.

Example: "Bad Request"
401invalid_client: wrong client_secret or unknown client_id.
errorstringrequired

An OAuth 2.0 error code.

invalid_requestinvalid_clientinvalid_grantredirect_uri_mismatchunsupported_grant_typeinvalid_token
error_descriptionstring

Human-readable text with additional information.

Example: "Bad Request"