Please enable JavaScript to view this site.

A-Shell 6.5 Development Notes

Navigation: Notes by Version and Date > 2022 > 1717 — 04 Aug 2022

ASHNET Function Requests Google Token

Scroll Prev Top Next More

ASHNET library enhancement (1.4.184): New function exposed to request a Google API access token based on a private key. This was added specifically to facilitate downloading a file from Google Cloud Storage when the private key is supplied by the owner, but is potentially useful in other contexts as well. The function can be called via DYNLIB as follows:

funcsig$ = "GetGoogleCloudAccessToken(Zziz)i"

xcall DYNLIB, dlctl, funcsig$, prvkey$, token$, sizeof(token$), url, rc

Parameters

prvkey$ (String)  [in]

is a json string containing a private key, something like:

{

"type": "service_account",

"project_id": "chilkattest-1350",

"private_key_id": "fa2e36ee26986eab628b59868af8bec1d1c64c38",

"private_key": "-----BEGIN PRIVATE KEY-----\nMII....jSdy\n-----END PRIVATE KEY-----\n",

"client_email": "598922945xxxxxxxxxxxxa@developer.gserviceaccount.com",

"client_id": "5989229452xxxxxxxxxxxxxxxxa.apps.googleusercontent.com",

"auth_uri": "https:!accounts.google.com/o/oauth2/auth",

"token_uri": "https://accounts.google.com/o/oauth2/token",

"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",

"client_x509_cert_url": "https://www.googleapis.com/robot/v1/m...com"

}

 

token$ (String,2048)  [out]

receives the access token

cb (Num)  [in]

specifies the size of the token$ parameter

url (String)  [in]

optional url; default: https://www.googleapis.com/auth/cloud-platform

rc (I4)  [out]

return code (0 for success, else ANETERR_xxx codes)