Will generate a URL safe Base 64 encoded signature for a Google Service Account using JWT (JSON Web Token).
This function is for use when you want to use a Google OAuth 2.0 Server to Server application within a DriveWorks Project.
This could be used to access Google Sheets for example.
For more information click here for the Google Technical Documentation about creating Signatures for use with Server to Server authentications.
SppGoogleAuthenticationJwtSignature([Header],[Claim Set],[Key Path],[Certificate Password])
Where:
Header is a string, not in Base 64 encoded format, needed to create the signature.
Claim Set is a string, not in Base 64 encoded format, need to create the signature
Key Path is the Full File Path to the location where the key is stored. This key is the file created in your Google Project page.
Certificate Password is the password to use.
The Claim Set needs to contain certain information and be formatted in a certain way. Below are the different elements needed for the Claim set String.
Name | Description |
---|---|
iss | The email address of the service account. |
scope | A space-delimited list of the permissions that the application requests. |
aud | A descriptor of the intended target of the assertion. When making an access token request this value is always https://www.googleapis.com/oauth2/v4/token |
exp | The expiration time of the assertion, specified as seconds since 00:00:00 UTC, January 1, 1970. This value has a maximum of 1 hour after the issued time. |
iat | The time the assertion was issued, specified as seconds since 00:00:00 UTC, January 1, 1970. |
Rule | Result | Meaning |
---|---|---|
SppGoogleAuthenticationJwtSignature(DWVariableGoogleHeader, DWVariableGoogleClaimSet, "C:\MyDocuments\TokenFile\sincere-etching-211910-36e9e936db22.p12", "notasecret") | So7zHWziHtW0D/iFakjxrbeDSTuG/LbP/iuzWKX2Qveb/hrldOxw... | This is the JWT signature that can be used to request a token to start the authentication process. |
Here is an example value for the Variable DWVariableGoogleHeader.
Example Header Rule |
---|
"{"&
SppQuotationSurround("alg")&":"& SppQuotationSurround("RS256")&","& SppQuotationSurround("typ")&":"& SppQuotationSurround("JWT") &"}" |
Here is an example value for the Variable DWVariableGoogleClaimSet.
Example Claim Set Rule |
---|
"{"&
SppQuotationSurround("iss")&":"&"761326798069-r5mljlln1rd4lrbhg75efgigp36m78j5@developer.gserviceaccount.com"&","& SppQuotationSurround("scope")&":"&"https://www.googleapis.com/auth/devstorage.readonly"&","& SppQuotationSurround("aud")&":"&"https://www.googleapis.com/oauth2/v4/token"&","& SppQuotationSurround("exp")&":"&(SppUnixEpoch() + 3600)&","& SppQuotationSurround("iat")&":"&SppUnixEpoch()&"," &"}" |