What is VBAuth

What is VBAuth? #

VBAuth — Technical White Paper #

Authenticating Microsoft 365 Graph API Calls from VBA

Version 1.0 — March 2026 Peter Bryant, Corylus Business Systems / Andrew Richards, The IT Service Ltd


The Problem VBAuth Solves #

For many years, Access and Excel developers used Outlook’s COM object model to send emails, read contacts, and interact with calendars on behalf of their users. That approach is no longer reliable. Microsoft’s rollout of New Outlook, combined with the enforcement of multi-factor authentication (MFA) and modern security policies across Microsoft 365 tenants, has progressively broken the traditional Outlook.Application COM automation model.

The correct replacement is Microsoft’s Graph API — a well-documented, REST-based interface that exposes the full range of Microsoft 365 services, from email and calendar to contacts, groups, audit logs, and beyond. Graph API calls require OAuth2 authentication, which in turn requires an interactive browser-based login flow that is fundamentally incompatible with the VBA environment as it stands.

VBAuth bridges that gap. It is a COM-visible .NET Framework 4.8 DLL that handles the entire OAuth2 authentication flow on behalf of a VBA application, returning an access token that the calling code can use immediately in Graph API HTTP requests.


What VBAuth Is #

VBAuth exposes a single COM class — VBAuth.GraphAuthenticator — which is registered with Windows during installation and is therefore callable from any VBA environment including Microsoft Access and Microsoft Excel.

The class exposes three methods and one property to VBA:

  • GetAccessToken(appClientId, tenantId, scopeCsv) — performs OAuth2 authentication and returns a JSON result containing the access token.
  • CheckDependencies() — verifies that all required supporting DLLs are present and at the correct version, and returns a detailed JSON report.
  • CheckLicence(tenantId) — validates the licence file(s) present in the installation folder against the supplied tenant ID, and returns a JSON report of each file’s status.
  • DllLocation (property) — returns the full path to the folder from which VBAuth.dll was loaded. Useful for diagnostic purposes.

All methods return JSON strings, making them straightforward to parse in VBA without any additional libraries.


Installation and File Layout #

VBAuth installs to C:\Program Files\VBAuth\Graph Authenticator regardless of whether the host machine runs 32-bit or 64-bit Office. This is intentional: VBAuth is a system-level COM component, and Program Files (not Program Files (x86)) is the correct location for components that operate at the Windows system level. The installer selects the correct bit-specific DLL build for the Office installation present on the machine, but both the 32-bit and 64-bit builds install to the same location.

After installation, the folder contains:

  • VBAuth.dll — the main COM DLL (32-bit or 64-bit build as appropriate)
  • VBAuth.tlb — the type library, used by VBA to provide IntelliSense
  • A set of supporting dependency DLLs (MSAL, IdentityModel, and related .NET runtime libraries)

The .LIC licence file — issued separately by the developer — must also be placed in this folder. VBAuth will not authenticate without a valid licence file present.


Licence Files #

Each deployment of a VBA application that uses VBAuth requires a .LIC file. Licence files are issued by the VBAuth vendor and are specific to the client tenant: each file encodes both the developer’s tenant ID (as a watermark identifying whose product this is) and the client tenant ID for which it is valid. Licence files are also time-limited, with an explicit expiry date encoded within them.

Licence files are cryptographically signed. VBAuth verifies the signature of every licence file it reads and will reject any file that has been tampered with, has expired, or does not match the tenant ID passed to GetAccessToken.

Naming Convention #

The recommended filename for a licence file is {ClientTenantID}.LIC — i.e. the client’s Azure tenant GUID followed by the .LIC extension. VBAuth will accept any filename with a .LIC extension, but using the tenant GUID as the filename enables a performance optimisation described below.

Location #

Licence files must be placed in the same folder as VBAuth.dll — that is, C:\Program Files\VBAuth\Graph Authenticator. This is a protected system folder; placing the licence file here prevents casual tampering by end users. Your installation process or procedure should ensure the .LIC file is placed here during deployment.

Multiple Licence Files and Performance #

A single installation folder may contain multiple .LIC files — for example, during development when a developer is testing against more than one client tenant. VBAuth handles this cleanly: when GetAccessToken is called, it scans all .LIC files in the installation folder.

To avoid unnecessary file reads, VBAuth prioritises any .LIC file whose filename exactly matches the tenant ID being authenticated. If a file named {tenantId}.LIC is found, it is evaluated first. Only if that file is absent, invalid, or expired does VBAuth fall back to scanning the remaining files. This means that in a well-organised deployment — where each licence file is named after the tenant it serves — the overhead of multiple files is negligible regardless of how many are present.


The Authentication Flow #

When GetAccessToken is called, the following sequence occurs:

  1. Integrity verification. VBAuth checks that the DLL itself has not been tampered with, verifying its digital code-signing certificate and strong name. If either check fails, a SecurityException is raised and no further processing occurs.


  2. Dependency verification. VBAuth checks that all required supporting DLLs are present in the installation folder and meet the minimum version requirements. If any dependency is missing or out of date, the call fails with a structured JSON error identifying the specific problem.


  3. Parameter validation. The appClientId, tenantId, and scopeCsv parameters are validated. Both IDs must be valid GUIDs. The scope string must be non-empty and contain recognisable Microsoft Graph scope formats. All validation errors are collected and reported together.


  4. Licence validation. VBAuth locates and validates .LIC files as described above. If no valid licence is found for the supplied tenant ID, the call fails with a clear error message.


  5. OAuth2 authentication. VBAuth uses the Microsoft Authentication Library (MSAL) to perform an interactive OAuth2 login flow against https://login.microsoftonline.com/{tenantId}. An embedded WebView2 browser control is used where available; if WebView2 is not installed on the machine, VBAuth automatically falls back to the user’s default system browser. In both cases, the user sees a standard Microsoft login prompt.


  6. Token return. On successful authentication, MSAL returns an access token. VBAuth Base64-encodes the token and embeds it in the JSON response. The calling VBA code decodes the Base64 value to obtain the raw JWT bearer token for use in Graph API HTTP requests.



The JSON Response #

Every call to GetAccessToken returns a JSON string with the following fields:

FieldDescription
successBoolean — true if authentication succeeded
access_tokenBase64-encoded JWT bearer token (empty on failure)
expires_onISO 8601 timestamp indicating when the token expires
errorHuman-readable error message (empty on success)
exception.NET exception type name (empty on success)
detailsAdditional diagnostic detail where available
dataStructured JSON data for diagnostic methods (null for GetAccessToken)
logFull path to the VBAuth log file

The log field is always populated, even on failure — making it straightforward for a VBA error handler to tell the user or developer exactly where to find the diagnostic log.


The Log File #

VBAuth writes a diagnostic log to the Windows temporary files folder: %TEMP%\VBAuth.log. Every significant event during a call — DLL integrity checks, dependency checks, licence validation, authentication attempts, and errors — is recorded with a UTC timestamp.

Log Rollover #

The log file is capped at 512 KB. When this limit is reached, the current log is renamed to VBAuth_old.log and a new VBAuth.log is started. Old logs are automatically deleted after 60 days.

RDP and Multi-User Environments #

The use of %TEMP%\VBAuth.log is deliberate and important for Remote Desktop (RDP) environments. Each user’s VBAuth log is entirely private to their own session — one user cannot see another user’s log, and there is no contention between concurrent sessions writing to the same file. This is the correct and safe behaviour for a server-hosted Access application.

Developers can retrieve the log path programmatically at any time from the log field in any VBAuth JSON response, or from the DllLocation property to derive the installation folder.


Error Handling Behaviour #

VBAuth is designed never to raise an unhandled exception back to the VBA caller. All anticipated and unanticipated errors are caught, logged, and returned as structured JSON failure responses. The success field will be false, and the error and exception fields will describe what went wrong.

The categories of error a calling application may encounter are:

  • DLL integrity failure — the DLL has been tampered with or its certificate has expired. The application should refuse to continue and alert the user.
  • Dependency failure — one or more supporting DLLs are missing or at the wrong version. The data field contains a detailed per-dependency report. This is most likely to occur after a partial or incomplete installation.
  • Licence failure — no valid .LIC file was found for the tenant. The error message includes the URL to purchase or renew.
  • Parameter validation failure — the calling code passed invalid arguments. These errors indicate a development-time issue.
  • Authentication failure — the user cancelled the login, the session timed out, or Microsoft rejected the authentication. The MSAL error detail is included in the response.
  • WebView2 fallback — not an error, but logged: if the embedded browser fails and the system browser is used instead, this is recorded in the log.

Using VBAuth from VBA #

A minimal VBA call looks like this:

Dim objAuth  As Object
Dim strJSON  As String
Dim strToken As String

Set objAuth = CreateObject("VBAuth.GraphAuthenticator")

strJSON = objAuth.GetAccessToken( _
    "your-app-client-id-guid", _
    "your-tenant-id-guid", _
    "https://graph.microsoft.com/.default")

' Parse strJSON to extract access_token, then Base64-decode it
' to obtain the raw bearer token for use in HTTP headers
Code language: PHP (php)

The token returned in access_token is Base64-encoded. The VBA calling code must decode it once to obtain the raw JWT for use in Authorization: Bearer headers in subsequent Graph API HTTP calls.

The demonstration database included with VBAuth provides fully working source code for six Graph API operations — including sending email, reading contacts, retrieving group membership, listing bookings, and reading the Azure audit log — illustrating the complete pattern from authentication through to API call and response handling.


Security Considerations #

  • VBAuth.dll is digitally code-signed. The signature is verified on every call.
  • Licence files are RSA-4096 signed and cannot be forged or modified without the signing key.
  • Licence files encode both the developer’s and the client’s tenant IDs, providing watermarking and audit capability.
  • The access token is never written to the log file.
  • The installation folder (C:\Program Files\VBAuth\Graph Authenticator) is a protected system location; standard user accounts cannot modify its contents.

VBAuth, developed and maintained by Andrew Richards (The IT Service Ltd) and Peter Bryant (Corylus Business Systems), © 2025–2026. All rights reserved. https://vbauth.com

Updated on April 19, 2026