I run the following command in PowerShell:
curl.exe -X POST https://app.inventorum.com/api/auth/token/ -u '$CLIENTID:$CLIENTSECRET' -d 'grant_type=refresh_token&refresh_token=$REFRESHTOKEN'
It returns a valid new refresh and bearer token.
How can this be done in VBA in Excel?
Private Function getAccessToken() As String
Dim httpRequest As New WinHttpRequest
Dim apiUrl As String
apiUrl = "https://app.inventorum.com/api/auth/token/"
httpRequest.Open "POST", apiUrl
httpRequest.SetCredentials clientId, clientSecret, 0
httpRequest.send "grant_type=refresh_token&refresh_token=" & refreshToken
Debug.Print httpRequest.responseText
End Function
The returned response:
{"error": "unsupported_grant_type"}
curl.exe(a cmd.exe executable, thus cmd.exe is handling this call) directly and notcurl(aka Invoke-WebRequest). So, you are looking for help with VBA, not PS in any way. What did you search for?curlis accessible under curl.exe as explained here: stackoverflow.com/a/30807818/1626443. Second, it's a "translation problem" because several methods produce different results and PowerShell provides me with the correct result and thus I included it.