question

figtrees15 avatar image
0 Likes"
figtrees15 asked ·

Cant get oauth2 token (Internal Server Error)

I am using an 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.


Code sample 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)

oauth2token errorauth-token
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

patbo-4981 avatar image
0 Likes"
patbo-4981 answered ·

When you create your application profile at YDN you must make sure to select at least one API permission. For example try "Profiles (Social Directory) Read Public".

If your application has no API permissions then token generation will fail just the way you described.

If you already created an application with no permissions then you will have to delete it and create it again.



prepaidgiftbalance

· 1 ·
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 @patb0-4981 I am new to coding can you explain more, What is YDN and what do I create an application profile? I though that some of the oauth scopes were granted automatically Thanks

0 Likes 0 ·