VBA-tools / VBA-Web

VBA-Web: Connect VBA, Excel, Access, and Office for Windows and Mac to web services and the web
http://vba-tools.github.io/VBA-Web/
MIT License
1.98k stars 490 forks source link

Error with OAuth1.0 Authentication #492

Open DLHeinze opened 6 months ago

DLHeinze commented 6 months ago

I'm trying to use OAuth1.0 to authenticate to an API. I am getting an error when it's preparing the http request.

The code is very simple. It builds just fine until I add the authentication part.

Any ideas?

ERROR - WebClient.Execute: -2147210493 (11011 / 80042b03), An error occurred during execute -2147210492 (80042b04): An error occurred while preparing http request -2146232576 (80131700): Automation error

Function Get_SingleRecord() As String
    Dim Client As New WebClient
    Client.BaseUrl = kBaseURL & "/"

    ' Setup authenticator
    Dim Auth As New OAuth1Authenticator
    Auth.Setup _
        ConsumerKey:=kconsumer_key, _
        ConsumerSecret:=kconsumer_secret, _
        Token:=koauth_token, _
        TokenSecret:=koauth_token_secret
    Set Client.Authenticator = Auth

    ' Use GetJSON helper to execute simple request and work with response
    Dim Resource As String
    Dim Response As WebResponse
    Resource = "restapi/1.0/object/contact/3"
    Set Response = Client.GetJson(Resource)
End Function
DLHeinze commented 6 months ago

The error was at this line: Set web_Crypto = CreateObject("System.Security.Cryptography.HMACSHA1")

Solution: Installed MS .NET Framework 3.5