Exchange Google ID token for Auth0 tokens
curl --request POST \
--url https://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google \
--header 'Content-Type: application/json' \
--data '
{
"idToken": "<string>"
}
'import requests
url = "https://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google"
payload = { "idToken": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({idToken: '<string>'})
};
fetch('https://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google', 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://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google",
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([
'idToken' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google"
payload := strings.NewReader("{\n \"idToken\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google")
.header("Content-Type", "application/json")
.body("{\n \"idToken\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"idToken\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"accessToken": "<string>",
"idToken": "<string>",
"refreshToken": "<string>",
"expiresIn": 123,
"user": {
"id": "<string>",
"email": "jsmith@example.com",
"name": "<string>",
"picture": "<string>",
"emailVerified": true,
"phone": "<string>"
}
},
"meta": {
"timestamp": "2023-11-07T05:31:56Z",
"requestId": "<string>"
}
}{
"success": false,
"error": {
"message": "Please enter a valid 10-digit phone number (e.g., 9876543210)",
"code": "VALIDATION_ERROR",
"details": [
{
"field": "phone",
"message": "Please enter a valid 10-digit phone number (e.g., 9876543210)"
}
]
},
"meta": {
"timestamp": "2023-11-07T05:31:56Z",
"requestId": "<string>"
}
}{
"success": false,
"error": {
"message": "Please enter a valid 10-digit phone number (e.g., 9876543210)",
"code": "VALIDATION_ERROR",
"details": [
{
"field": "phone",
"message": "Please enter a valid 10-digit phone number (e.g., 9876543210)"
}
]
},
"meta": {
"timestamp": "2023-11-07T05:31:56Z",
"requestId": "<string>"
}
}Auth service
Google OAuth (Token Exchange)
POST
/
api
/
v1
/
auth
/
google
Exchange Google ID token for Auth0 tokens
curl --request POST \
--url https://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google \
--header 'Content-Type: application/json' \
--data '
{
"idToken": "<string>"
}
'import requests
url = "https://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google"
payload = { "idToken": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({idToken: '<string>'})
};
fetch('https://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google', 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://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google",
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([
'idToken' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google"
payload := strings.NewReader("{\n \"idToken\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google")
.header("Content-Type", "application/json")
.body("{\n \"idToken\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://handauncle-backend-prod-205012263523.asia-south1.run.app/api/v1/auth/google")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"idToken\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"accessToken": "<string>",
"idToken": "<string>",
"refreshToken": "<string>",
"expiresIn": 123,
"user": {
"id": "<string>",
"email": "jsmith@example.com",
"name": "<string>",
"picture": "<string>",
"emailVerified": true,
"phone": "<string>"
}
},
"meta": {
"timestamp": "2023-11-07T05:31:56Z",
"requestId": "<string>"
}
}{
"success": false,
"error": {
"message": "Please enter a valid 10-digit phone number (e.g., 9876543210)",
"code": "VALIDATION_ERROR",
"details": [
{
"field": "phone",
"message": "Please enter a valid 10-digit phone number (e.g., 9876543210)"
}
]
},
"meta": {
"timestamp": "2023-11-07T05:31:56Z",
"requestId": "<string>"
}
}{
"success": false,
"error": {
"message": "Please enter a valid 10-digit phone number (e.g., 9876543210)",
"code": "VALIDATION_ERROR",
"details": [
{
"field": "phone",
"message": "Please enter a valid 10-digit phone number (e.g., 9876543210)"
}
]
},
"meta": {
"timestamp": "2023-11-07T05:31:56Z",
"requestId": "<string>"
}
}Exchange a Google ID token (obtained via the native/mobile SDK) for Auth0
accessToken, idToken, and refreshToken. The backend also syncs the user
record into MongoDB on first login.
Testing with the Token Generator Tool
We provide a simple HTML tool to generate Google ID tokens for testing your API locally.Prerequisites
- A Google OAuth Client ID from Google Cloud Console
- Make sure
http://localhost:3000is added to the Authorized JavaScript origins in your OAuth client configuration
Running the Token Generator
1
Start the local server
From the project root, run:This starts a static file server on
npx serve -l 3000
http://localhost:3000.2
Open the token generator
Navigate to http://localhost:3000/test-google-token.html in your browser.
3
Enter your Client ID
Paste your Google OAuth Client ID into the input field and press Enter or click the “Sign in with Google” button.
4
Sign in with Google
Complete the Google sign-in flow. Once authenticated, your ID token will be displayed.
5
Use the token
Copy the token and use it to test the
/api/v1/auth/google endpoint:curl -X POST http://localhost:8080/api/v1/auth/google \
-H "Content-Type: application/json" \
-d '{"idToken": "YOUR_COPIED_TOKEN"}'
Features
| Feature | Description |
|---|---|
| Copy Token | One-click copy to clipboard |
| Test API | Built-in button to test your backend directly from the tool |
| cURL Example | Auto-generated cURL command with your token |
The token generator tool is for development and testing only. Never use it in production or expose your Client ID publicly.