- Shenbagam Balakumar
- PowerServer
- Wednesday, 22 May 2024 05:12 AM UTC
Hi Team,
I'm able to get access token using OAuthClient. Now, I need to get the claims (payload data ) from access token or id token. Please let me know how we can get the payload data in PowerBuilder.
//TokenRequest
ltr_Request.Method = "POST"
ltr_Request.tokenlocation = ls_url
ltr_Request.granttype = "authorization_code"
ltr_Request.clientid = ls_ClientID
ltr_Request.secureprotocol = 0
ltr_Request.clientsecret = ls_clientsecret
ltr_Request.scope = ls_Scope
ltr_Request.ClearParams()
ltr_Request.AppendParam("grant_type","authorization_code")
ltr_Request.AppendParam("client_id", ls_ClientID)
ltr_Request.AppendParam("client_secret", ls_clientsecret)
ltr_Request.AppendParam("scope", ls_Scope)
ltr_Request.AppendParam("code", ls_code)
ltr_Request.AppendParam("code_verifier", ls_verify_code)
ltr_Request.ClearHeaders()
ltr_Request.SetHeader("Content-Type","application/x-www-form-urlencoded")
loac_Client = Create OAuthClient
li_Return = loac_Client.AccessToken(ltr_Request, ltr_Response)
If li_Return = 1 and ltr_Response.GetStatusCode() = 200 Then
li_Return = ltr_Response.getbody(ls_token_body)
if li_Return = 1 THEN
JsonParser ljson_Parser
ljson_Parser = Create JsonParser
ljson_Parser.LoadString( ls_token_body )
ls_TokenType = ljson_Parser.GetItemString( "/token_type" )
ls_AccessToken = ljson_Parser.GetItemString( "/access_token" )
ll_Return = Getapplication().SetHttpRequestHeader( "Authorization", ls_TokenType + " " + ls_AccessToken, True )
End if
Else
li_Return = ltr_Response.GetTokenError(ls_type, ls_description, ls_uri, ls_state)
MessageBox("AccessToken Falied", "Return :" + String (li_Return) + "~r~n" + String(ltr_Response.GetStatusCode() )+ "~r~n" + ltr_Response.GetStatustext()+ "~r~n" + ls_description)
End If
Thanks in Advance!!
Shenbagam Balakumar.
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.