cURL
curl --request POST \
--url https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"redirect_url": "<string>",
"state": "<string>"
}
'import requests
url = "https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url"
payload = {
"redirect_url": "<string>",
"state": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({redirect_url: '<string>', state: '<string>'})
};
fetch('https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'redirect_url' => '<string>',
'state' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url"
payload := strings.NewReader("{\n \"redirect_url\": \"<string>\",\n \"state\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"redirect_url\": \"<string>\",\n \"state\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"redirect_url\": \"<string>\",\n \"state\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"url": "https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fbusiness.manage&state=a1b2c3d4e5f6&redirect_uri=YOUR_CALLBACK_URL&client_id=YOUR_CLIENT_ID"
}OAuth
Generate Google OAuth URL
Generates a Google OAuth URL. Redirect the user to this URL. After they authorize, they are sent to your redirect_url with status=success or an error query parameter. redirect_url must be HTTPS.
POST
/
oauth
/
google
/
generate-url
cURL
curl --request POST \
--url https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"redirect_url": "<string>",
"state": "<string>"
}
'import requests
url = "https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url"
payload = {
"redirect_url": "<string>",
"state": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({redirect_url: '<string>', state: '<string>'})
};
fetch('https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'redirect_url' => '<string>',
'state' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url"
payload := strings.NewReader("{\n \"redirect_url\": \"<string>\",\n \"state\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"redirect_url\": \"<string>\",\n \"state\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gmbapi.com/external-api/gmb/oauth/google/generate-url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"redirect_url\": \"<string>\",\n \"state\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"url": "https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fbusiness.manage&state=a1b2c3d4e5f6&redirect_uri=YOUR_CALLBACK_URL&client_id=YOUR_CLIENT_ID"
}Requires an Organization token.
redirect_url must be HTTPS.
- Call this endpoint with
redirect_urland optionalstate - Redirect the user to the returned
url - After they authorize, they are sent to your
redirect_url
userinfo.email, userinfo.profile, business.manage.
Success
https://your-redirect-url.com?status=success&account_id={account_id}&account_name={name}&state={state}
Errors
OAuth failures use?error=:
error | Meaning |
|---|---|
access_denied | User declined consent |
invalid_state | State validation failed |
invalid_grant | Required business.manage scope was not granted |
oauth_error | Unexpected callback error |
?status=error&error_message=:
error_message | Meaning |
|---|---|
ACCOUNT_ALREADY_CONNECTED | This Google account is already connected |
TOO_MANY_REQUESTS | An export is already in progress |
NO_LOCATION_FOUND | No locations found for this account |
INTERNAL_SERVER_ERROR | Unexpected error |
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
OAuth URL generation parameters