question

figtrees15 avatar image
0 Likes"
figtrees15 asked

internal Server Error getting oauth token

I am using VBA in an MS-Access database, I can get the authorization code with expiry time of 299 but when I try to get the access token, I get an 500 internal Server error returned in xmlHTTP.status and StatusText with and empty responseText.


Any advice greatly appreciated.


Code below:


' Get User Access token

strContentType = "application/x-www-form-urlencoded"

strClientID = strApp_ID

strClientSecret = strCert_ID


Dim strData As String


strData = "grant_type=authorization_code" & _

"code=" & strAuthorization_Code & _

"redirect_uri=" & strRedirect_uri


Dim xmlHTTP As New MSXML2.XMLHTTP60, myuri As String

myuri = strEndPoint

xmlHTTP.Open "POST", strEndPoint, False

xmlHTTP.setRequestHeader "Content-Type", "text/json"

xmlHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

xmlHTTP.setRequestHeader "User-Agent", "Mozilla/5.0"

xmlHTTP.setRequestHeader "Authorization", "Basic " + EncodeBase64(strClientID & ":" & strClientSecret)

xmlHTTP.Send strData


MsgBox (xmlHTTP.Status & " : " & xmlHTTP.StatusText)

MsgBox (xmlHTTP.responseText)

tokenoauth2internal server errorauth-token500 server error500 internal
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

alvisinwales avatar image
0 Likes"
alvisinwales answered

You have no ampersands in strData.


· 5
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @alvisinwales, Thank for you response but I have tried that and still get the same error.

strData as below:

grant_type=authorization_code&code=v%5.......D%3D&redirect_uri=Kev.....qs


0 Likes 0 ·

I do this using curl. Yours looks about the same but I only send the second of your Content-Type headers. Could this be the problem?


0 Likes 0 ·

if I take that line out I get a 400 : BadRequest. If I used curl how could I get the access token response back in to VBA, can you post an example please

0 Likes 0 ·
Show more comments