OAU-251 Am I building the body wrong?

  • 6 August 2023
  • 1 reply

Sub GetAccessToken()
  Dim MyRequest As Object
  Dim strJWT As String
  Dim strURL As String
  Dim strBody As String
  Dim strEncode64Base As String
  Dim strClientSecret As String
  Dim strClientID As String

  strURL = ""
  strJWT = "ey....Shortened..cfA"
  strClientSecret = "Jn....Shortened..rg"
  strClientID = "Lj....Shortened..FA"

  strEncode64Base = EncodeBase64(strClientID & ":" & strClientSecret)
  Debug.Print strEncode64Base

  strBody = "grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&" & "assertion=" & strJWT
  Debug.Print "STRBODY: " & strBody

  Set MyRequest = CreateObject("WinHttp.WinHttpRequest.5.1")

  MyRequest.Open "POST", strURL, False
  MyRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
  MyRequest.SetRequestHeader "Accept", "application/json"
  MyRequest.SetRequestHeader "Authorization", "Basic " & strEncode64Base
  MyRequest.Send strBody
  Debug.Print MyRequest.ResponseText
  Set MyRequest = Nothing
End Sub

Have I configured the account wrong?

is the Body wrong?

How should I format the body?

Thanks for any help you can provide.


1 reply

I found the issue. Mismatched credentials.......