VBA Authorization oauth2 API

北慕城南 提交于 2020-04-11 12:13:37

问题


Been stuck on this for a few days now. Trying to obtain access token from an API with oauth2 authentication.

But I keep getting '401 Unauthorized', "Full authentication is required'

My gues is i'm doing something wrong with the

 .SetRequestHeder "Authorization", "basic " + (base64 encoded)

Here's the code so far: (worked with another API)

Username = "myusername"
Password = "myclientsecret"

PasswordnUsername = Password & ":" & Username

    argumentString = "?grant_type=password&username=myusername&password=mypassword"

Set xmlhttp = CreateObject("MSXML2.XMLHTTP.6.0")
    xmlhttp.Open "POST", "https://api.url/partner/oauth/token", False
    xmlhttp.SetRequestHeader "Authorization", "basic " + mdl_API_MB_ACCESS_TOKEN.Base64Encode(PasswordnUsername)
    xmlhttp.SetRequestHeader "x-api-key", "myxapicode"
    xmlhttp.Send (argumentString)

来源:https://stackoverflow.com/questions/50610609/vba-authorization-oauth2-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!