Once you have a Verified Calls agent, you can register calls. However, there's no need to register a call or update a call's state if the call recipient doesn't support Verified Calls. Before you register a call, you can check the recipient device's capabilities to see if it supports Verified Calls.
Prerequisites
Before you can check if a recipient can receive Verified Calls, you need to gather some information:
GCP project with the Business Calls API enabled (After you've registered as a partner, enable the API here). Please make sure you have the correct project selected. If you use GCP a lot, the registered project may not be the default project selected.
GCP project's service account key (Download the service account here)
The recipient's phone number, in E.164 format (for example, "+12223334444")
Additionally, you need the
gcloud
command line tool
installed on your development machine.
Perform a capability check
To check a recipient's capabilities, run the following commands. Replace variables with values you identified in Prerequisites.
- Prepare your credentials.
cURL
export GOOGLE_APPLICATION_CREDENTIALS=PATH_TO_SERVICE_ACCOUNT_KEY
ACCESS_TOKEN="$(gcloud auth application-default print-access-token)"
Python
import json import os import time import jwt import requests service_account_path = PATH_TO_SERVICE_ACCOUNT_KEY current_time = round(time.time()) # Open the json service account key with open(service_account_path) as f: service_key = json.load(f) # Prepare the payload and headers for OAuth payload = { 'iss': service_key['client_email'], 'scope': 'https://www.googleapis.com/auth/businesscommunications https://www.googleapis.com/auth/cloud-platform', 'aud': 'https://oauth2.googleapis.com/token', 'exp': current_time + 3600, 'iat': current_time} additional_headers = {'kid': service_key['private_key']} # Encode the jwt signed_jwt = jwt.encode(payload, service_key['private_key'], headers=additional_headers, algorithm='RS256') # Prepare the data and make the OAUTH request data = { 'grant_type': 'urn:ietf:params:oauth:grant-type:jwt-bearer', 'assertion': signed_jwt } response = requests.post('https://oauth2.googleapis.com/token', data=data) # Save the access token token = json.loads(response.text)['access_token']
For full example see our client samples
Java/Node.js/PHP
For more examples see our client samples
- Check the recipient's capabilities.
cURL
curl -X POST "https://businesscalls.googleapis.com/v1:checkVcallDeviceReachable" \ -H "Content-Type: application/json" \ -H "User-Agent: curl/verified-calls" \ -H "Authorization: Bearer $ACCESS_TOKEN" \ -d "{ 'deviceNumber':'PHONE_NUMBER', }"
Python
headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer {}'.format(token), } data = {'deviceNumber': '+16400000000'} response = requests.post('https://businesscalls.googleapis.com/v1:checkVcallDeviceReachable', headers=headers, data=json.dumps(data)) print(response.content)
For full example see our client samples
Java/Node.js/PHP
For more examples see our client samples
The response includes a value of whether or not the recipient supports Verified Calls. If the response comes back UNREACHABLE for your test device, make sure you've followed the steps to become a beta tester. Otherwise, the number you're calling may be on an incompatible device, or has opted out of the feature.
Next steps
Now that you can check if a device supports Verified Calls, you can register calls.