PowerBuilder
PowerBuilder
Example: Http.SetAuthTokenSb method
Demonstrates theSetAuthTokenSb method.
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Http
string ls_Oauth2_access_token
oleobject loo_SbAccessToken
string ls_ResponseText
li_Success = 0
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
ls_Oauth2_access_token = "ya39.Ci-XA_C5bGgRDC3UaD-h0_NeL-DVIQnI2gHtBBBHkZzrwlARkwX6R3O0PCDEzRlfaQ"
loo_SbAccessToken = create oleobject
li_rc = loo_SbAccessToken.ConnectToNewObject("Chilkat.StringBuilder")
loo_SbAccessToken.Append(ls_Oauth2_access_token)
// Causes the "Authorization: Bearer <access_token>" header to be added to all HTTP requests.
loo_Http.SetAuthTokenSb(loo_SbAccessToken)
ls_ResponseText = loo_Http.QuickGetStr("https://chilkatsoft.com/helloWorld.txt")
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_SbAccessToken
return
end if
// See the HTTP request header that was sent.
Write-Debug loo_Http.LastHeader
// Output:
//
// GET /helloWorld.txt HTTP/1.1
// Host: chilkatsoft.com
// Accept: */*
// Accept-Encoding: gzip
// Authorization: Bearer ya39.Ci-XA_C5bGgRDC3UaD-h0_NeL-DVIQnI2gHtBBBHkZzrwlARkwX6R3O0PCDEzRlfaQ
// Note: Starting in v11.2.0, the information that should be kept secret in the Authorization header
// will be redacted. Thus, in Chilkat v11.2.0 and later, the LastHeader property will show the following:
// Authorization: Bearer ****
destroy loo_Http
destroy loo_SbAccessToken