AWS STS: Obtain an AWS-Signed JWT for an External Service
See more AWS Security Token Service Examples
Uses the AWS STS Query API version 2011-06-15 and a verified TLS connection to the commercial-partition regional endpoint sts.us-west-2.amazonaws.com. Change the endpoint and signing region together for your deployment. Assumes Chilkat is unlocked.
Keep qa_data/aws/sts.json private and outside web roots/source control. Signed examples require nonempty access_key and secret_key strings; temporary source credentials also require session_token and ISO 8601 expiration. Federation exchanges load their specific fields without AWS keys. The examples do not print credentials, bearer tokens, full responses or diagnostic dumps. Credential-producing examples build a complete in-memory session object with access_key, secret_key, session_token and expiration; integrate that object into your application before it goes out of scope.
Set audience to the intended external service. Requests RS256 with a five-minute lifetime from a regional STS endpoint; outbound federation must be enabled for the account. Optional subject_mode is AWSIdentity or OriginIdentity. OriginIdentity requires the caller's trusted identity propagation context. Optional scope is permitted only for OriginIdentity and this single audience, and requires sts:SetWebIdentityTokenScope in addition to sts:GetWebIdentityToken. Validates scope spacing, characters and duplicate values.
The returned token is an external identity JWT, not an AWS access key/session-token credential set. The recipient must validate its signature using the trusted issuer's JWKS, issuer, audience and lifetime; merely decoding it is insufficient. The request cannot extend the calling session's lifetime.
AWS references: GetWebIdentityToken
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loStringCompare
LOCAL loCredentials
LOCAL lnStringMatch1
LOCAL lnStringMatch2
LOCAL loExpires
LOCAL loNow
LOCAL lcRegion
LOCAL lnStringMatch3
LOCAL lnStringMatch4
LOCAL lnStringMatch5
LOCAL lcSubjectMode
LOCAL lnStringMatch6
LOCAL lnStringMatch7
LOCAL lnStringMatch8
LOCAL lnStringMatch9
LOCAL lnStringMatch10
LOCAL loScopeText
LOCAL loAllowedScope
LOCAL lnScopeIndex
LOCAL loScopeValues
LOCAL loSeenScopes
LOCAL lcScopeValue
LOCAL loEndpoint
LOCAL loAws
LOCAL loRest
LOCAL loConnection
LOCAL loXml
LOCAL lcValue
LOCAL lcSessionToken
LOCAL lcExpiration
LOCAL lcResponseXml
LOCAL lnStringMatch11
LOCAL lnStringMatch12
LOCAL lnStringMatch13
LOCAL lnStringMatch14
lnSuccess = 0
loStringCompare = CreateObject('Chilkat.StringBuilder')
* Assumes Chilkat is unlocked. See Global Unlock Sample.
* Keep this file private and outside public web content/source control.
loCredentials = CreateObject('Chilkat.JsonObject')
loCredentials.Strict = 1
lnSuccess = loCredentials.LoadFile("qa_data/aws/sts.json")
IF (lnSuccess <> 1) THEN
? "Could not load private STS configuration."
RELEASE loStringCompare
RELEASE loCredentials
CANCEL
ENDIF
loStringCompare.SetString(loCredentials.StringOf("access_key"))
lnStringMatch1 = loStringCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("access_key") <> 1) OR (lnStringMatch1 = 1)) THEN
? "Missing or invalid access_key."
RELEASE loStringCompare
RELEASE loCredentials
CANCEL
ENDIF
loStringCompare.SetString(loCredentials.StringOf("secret_key"))
lnStringMatch2 = loStringCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("secret_key") <> 1) OR (lnStringMatch2 = 1)) THEN
? "Missing or invalid secret_key."
RELEASE loStringCompare
RELEASE loCredentials
CANCEL
ENDIF
loExpires = CreateObject('Chilkat.CkDateTime')
loNow = CreateObject('Chilkat.CkDateTime')
lcRegion = "us-west-2"
IF (loCredentials.HasMember("session_token") = 1) THEN
loStringCompare.SetString(loCredentials.StringOf("session_token"))
lnStringMatch3 = loStringCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("session_token") <> 1) OR (lnStringMatch3 = 1)) THEN
? "Missing or invalid session_token."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
CANCEL
ENDIF
loStringCompare.SetString(loCredentials.StringOf("expiration"))
lnStringMatch4 = loStringCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("expiration") <> 1) OR (lnStringMatch4 = 1)) THEN
? "Missing or invalid expiration."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
CANCEL
ENDIF
lnSuccess = loExpires.SetFromTimestamp(loCredentials.StringOf("expiration"))
IF (lnSuccess <> 1) THEN
? "Source expiration is invalid."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
CANCEL
ENDIF
lnSuccess = loNow.SetFromCurrentSystemTime()
IF (lnSuccess <> 1) THEN
? "Could not read current time."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
CANCEL
ENDIF
IF (loExpires.DiffSeconds(loNow) <= 60) THEN
? "Source credentials are expired or expire within 60 seconds; obtain fresh credentials."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
CANCEL
ENDIF
ENDIF
loStringCompare.SetString(loCredentials.StringOf("audience"))
lnStringMatch5 = loStringCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("audience") <> 1) OR (lnStringMatch5 = 1)) THEN
? "Missing or invalid audience."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
CANCEL
ENDIF
* Use AWSIdentity by default. OriginIdentity requires trusted propagation context.
lcSubjectMode = "AWSIdentity"
IF (loCredentials.HasMember("subject_mode") = 1) THEN
loStringCompare.SetString(loCredentials.StringOf("subject_mode"))
lnStringMatch6 = loStringCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("subject_mode") <> 1) OR (lnStringMatch6 = 1)) THEN
? "Missing or invalid subject_mode."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
CANCEL
ENDIF
lcSubjectMode = loCredentials.StringOf("subject_mode")
ENDIF
loStringCompare.SetString(lcSubjectMode)
lnStringMatch7 = loStringCompare.ContentsEqual("AWSIdentity",1)
loStringCompare.SetString(lcSubjectMode)
lnStringMatch8 = loStringCompare.ContentsEqual("OriginIdentity",1)
IF ((lnStringMatch7 <> 1) AND (lnStringMatch8 <> 1)) THEN
? "Invalid subject_mode."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
CANCEL
ENDIF
IF (loCredentials.HasMember("scope") = 1) THEN
loStringCompare.SetString(loCredentials.StringOf("scope"))
lnStringMatch9 = loStringCompare.ContentsEqual("",1)
IF ((loCredentials.JsonTypeOf("scope") <> 1) OR (lnStringMatch9 = 1)) THEN
? "Missing or invalid scope."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
CANCEL
ENDIF
loStringCompare.SetString(lcSubjectMode)
lnStringMatch10 = loStringCompare.ContentsEqual("OriginIdentity",1)
IF (lnStringMatch10 <> 1) THEN
? "scope requires OriginIdentity."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
CANCEL
ENDIF
loScopeText = CreateObject('Chilkat.StringBuilder')
loScopeText.Append(loCredentials.StringOf("scope"))
IF ((loScopeText.Length > 256) OR (loScopeText.StartsWith(" ",1) = 1) OR (loScopeText.EndsWith(" ",1) = 1) OR (loScopeText.Contains(" ",1) = 1)) THEN
? "Invalid scope length or spacing."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
CANCEL
ENDIF
loAllowedScope = CreateObject('Chilkat.StringBuilder')
loAllowedScope.Append("!#$%&'()*+-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~ ")
lnScopeIndex = 0
DO WHILE (lnScopeIndex < loScopeText.Length)
IF (loAllowedScope.Contains(loScopeText.GetRange(lnScopeIndex,1,0),1) <> 1) THEN
? "Invalid scope character."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
CANCEL
ENDIF
lnScopeIndex = lnScopeIndex + 1
ENDDO
loScopeValues = CreateObject('Chilkat.StringTable')
lnSuccess = loScopeValues.SplitAndAppend(loScopeText.GetAsString()," ",0,0)
IF (lnSuccess <> 1) THEN
? "Could not split scope values."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
CANCEL
ENDIF
loSeenScopes = CreateObject('Chilkat.Hashtable')
lnScopeIndex = 0
DO WHILE (lnScopeIndex < loScopeValues.Count)
lcScopeValue = loScopeValues.StringAt(lnScopeIndex)
IF (loSeenScopes.Contains(lcScopeValue) = 1) THEN
? "Duplicate scope value."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
CANCEL
ENDIF
lnSuccess = loSeenScopes.AddStr(lcScopeValue,"seen")
IF (lnSuccess <> 1) THEN
? "Could not track scope values."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
CANCEL
ENDIF
lnScopeIndex = lnScopeIndex + 1
ENDDO
ENDIF
loEndpoint = CreateObject('Chilkat.StringBuilder')
loEndpoint.Append("sts.")
loEndpoint.Append(lcRegion)
loEndpoint.Append(".amazonaws.com")
loAws = CreateObject('Chilkat.AuthAws')
loAws.AccessKey = loCredentials.StringOf("access_key")
loAws.SecretKey = loCredentials.StringOf("secret_key")
loAws.Region = lcRegion
loAws.ServiceName = "sts"
loAws.SignatureVersion = 4
loRest = CreateObject('Chilkat.Rest')
loRest.ConnectTimeoutMs = 20000
loRest.IdleTimeoutMs = 60000
loRest.VerboseLogging = 0
lnSuccess = loRest.SetAuthAws(loAws)
IF (lnSuccess <> 1) THEN
? "Could not configure request signing."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
CANCEL
ENDIF
* Keep this verified Socket alive while Rest uses its connection.
loConnection = CreateObject('Chilkat.Socket')
loConnection.RequireSslCertVerify = 1
loConnection.MaxReadIdleMs = 60000
loConnection.MaxSendIdleMs = 60000
lnSuccess = loConnection.Connect(loEndpoint.GetAsString(),443,1,20000)
IF (lnSuccess <> 1) THEN
? "TLS connection failed; inspect diagnostics privately."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
CANCEL
ENDIF
lnSuccess = loRest.UseConnection(loConnection,1)
IF (lnSuccess <> 1) THEN
? "Could not attach TLS connection."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
CANCEL
ENDIF
loXml = CreateObject('Chilkat.Xml')
loXml.Strict = 1
lcResponseXml = ""
lnSuccess = loRest.ClearAllQueryParams()
IF (lnSuccess <> 1) THEN
? "Could not reset request parameters."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
lnSuccess = loRest.AddQueryParam("Action","GetWebIdentityToken")
IF (lnSuccess <> 1) THEN
? "Could not set Action."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
lnSuccess = loRest.AddQueryParam("Version","2011-06-15")
IF (lnSuccess <> 1) THEN
? "Could not set Version."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
IF (loCredentials.HasMember("session_token") = 1) THEN
lnSuccess = loRest.AddQueryParam("X-Amz-Security-Token",loCredentials.StringOf("session_token"))
IF (lnSuccess <> 1) THEN
? "Could not set X-Amz-Security-Token."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
ENDIF
lnSuccess = loRest.AddQueryParam("Audience.member.1",loCredentials.StringOf("audience"))
IF (lnSuccess <> 1) THEN
? "Could not set Audience.member.1."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
lnSuccess = loRest.AddQueryParam("SigningAlgorithm","RS256")
IF (lnSuccess <> 1) THEN
? "Could not set SigningAlgorithm."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
lnSuccess = loRest.AddQueryParam("DurationSeconds","300")
IF (lnSuccess <> 1) THEN
? "Could not set DurationSeconds."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
lnSuccess = loRest.AddQueryParam("SubjectMode",lcSubjectMode)
IF (lnSuccess <> 1) THEN
? "Could not set SubjectMode."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
IF (loCredentials.HasMember("scope") = 1) THEN
lnSuccess = loRest.AddQueryParam("Scope",loCredentials.StringOf("scope"))
IF (lnSuccess <> 1) THEN
? "Could not set Scope."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
ENDIF
lcResponseXml = loRest.FullRequestFormUrlEncoded("POST","/")
IF (loRest.LastMethodSuccess <> 1) THEN
? "STS transport failed; inspect diagnostics privately."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
IF (loRest.ResponseStatusCode <> 200) THEN
? "STS HTTP status: " + STR(loRest.ResponseStatusCode)
lnSuccess = loXml.LoadXml(lcResponseXml)
IF (lnSuccess = 1) THEN
lcValue = loXml.GetChildContent("Error|Code")
IF (loXml.LastMethodSuccess = 1) THEN
? "AWS error code: " + lcValue
ENDIF
lcValue = loXml.GetChildContent("RequestId")
IF (loXml.LastMethodSuccess = 1) THEN
? "AWS request ID: " + lcValue
ENDIF
ENDIF
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
lnSuccess = loXml.LoadXml(lcResponseXml)
IF (lnSuccess <> 1) THEN
? "Invalid STS XML response."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
loStringCompare.SetString(loXml.Tag)
lnStringMatch11 = loStringCompare.ContentsEqual("GetWebIdentityTokenResponse",1)
IF (lnStringMatch11 <> 1) THEN
? "Unexpected STS response root."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
lcValue = loXml.GetChildContent("ResponseMetadata|RequestId")
loStringCompare.SetString(lcValue)
lnStringMatch12 = loStringCompare.ContentsEqual("",1)
IF ((loXml.LastMethodSuccess <> 1) OR (lnStringMatch12 = 1)) THEN
? "Missing or empty ResponseMetadata|RequestId."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
IF (loXml.HasChildWithTag("GetWebIdentityTokenResult") <> 1) THEN
? "Missing STS result."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
lcSessionToken = loXml.GetChildContent("GetWebIdentityTokenResult|WebIdentityToken")
loStringCompare.SetString(lcSessionToken)
lnStringMatch13 = loStringCompare.ContentsEqual("",1)
IF ((loXml.LastMethodSuccess <> 1) OR (lnStringMatch13 = 1)) THEN
? "Missing or empty GetWebIdentityTokenResult|WebIdentityToken."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
lcExpiration = loXml.GetChildContent("GetWebIdentityTokenResult|Expiration")
loStringCompare.SetString(lcExpiration)
lnStringMatch14 = loStringCompare.ContentsEqual("",1)
IF ((loXml.LastMethodSuccess <> 1) OR (lnStringMatch14 = 1)) THEN
? "Missing or empty GetWebIdentityTokenResult|Expiration."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
lnSuccess = loExpires.SetFromTimestamp(lcExpiration)
IF (lnSuccess <> 1) THEN
? "JWT expiration is invalid."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
lnSuccess = loNow.SetFromCurrentSystemTime()
IF (lnSuccess <> 1) THEN
? "Could not read current time."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
IF (loExpires.DiffSeconds(loNow) <= 60) THEN
? "JWT credentials are expired or expire within 60 seconds; obtain fresh credentials."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml
CANCEL
ENDIF
* Hand sessionToken to the intended external service over TLS; never log it.
? "Web identity token obtained; expiration: " + lcExpiration
? "Example completed."
RELEASE loStringCompare
RELEASE loCredentials
RELEASE loExpires
RELEASE loNow
RELEASE loScopeText
RELEASE loAllowedScope
RELEASE loScopeValues
RELEASE loSeenScopes
RELEASE loEndpoint
RELEASE loAws
RELEASE loRest
RELEASE loConnection
RELEASE loXml