I have the following command that I run 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. But I cannot for the life of me get this 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"}
I don't know what I am doing wrong. I also cannot get it done in Insomnia, but this is a separate issue.