Skip to content

Authentication

Tim Hall edited this page Jan 16, 2015 · 3 revisions

VBA-Web comes with a few authenticators out-of-the-box and you can create your own

Set up an existing authenticator

(Make sure the desired authenticator class is included in the project)

Dim Client As New WebClient

' Create a new IAuthenticator implementation
Dim Auth As New ...Authenticator
' Setup authenticator...

' Attach the authenticator to the client
Set Client.Authenticator = Auth

HTTP Basic Authenticator

This is the standard Username + Password flow.

Note: The Username and Password are encoded, but not encrypted so https must be used when accessing services for the transmission to be secure

Dim Auth As New HttpBasicAuthenticator
Auth.Setup _
    Username:="Your username", _
    Password:="Your password"

OAuth 1.0

This is the standard OAuth 1.0 flow, using a Consumer key and secret, and Token key and secret to authorize requests.

Dim Auth As new OAuth1Authenticator
Auth.Setup _
    ConsumerKey:="Your consumer key", _
    ConsumerSecret:="Your consumer secret", _
    Token:="Your token", _
    TokenSecret:="Your token secret", _
    Realm:="Optional realm"

OAuth 2.0 - Client-credentials flow

Currently VBA-Web supports only the client-credentials flow of OAuth 2.0.

Notes:

  • This authenticator was developed specifically for Salesforce implementation, so it may not be compatible with other APIs that implement OAuth 2.0.
  • The Username and Password are encoded, but not encrypted so https must be used when accessing services for the transmission to be secure
Dim Auth As new OAuth2Authenticator
Auth.Setup _
    ClientId:="Your client id", _
    ClientSecret:="Your client secret", _
    Username:="Your username", _
    Password:="Your password"

Can't find an authenticator that meets your needs? Create your own! Check out the Implementing your own IAuthenticator example for details.