Dear @ALH,
Thank you for contacting the Microsoft 365 Q&A forum community support team. Dealing with temporary passwords and sync delays just to run a critical tool is certainly not ideal. You've hit on a common challenge when legacy tools built with VBA/Excel need to adapt to modern security protocols like Single Sign-On (SSO).
Unfortunately, VBA and the standard Excel data connection tools (like the legacy Web Query) do not have built-in support for modern, browser-based Single Sign-On (SSO) or multi-factor authentication (MFA) processes which typically rely on protocols like OAuth 2.0 or SAML.
The SSO process requires interaction with a web browser to handle redirection, credentials, and tokens, which is beyond the scope of VBA's simple HTTP request capabilities or the Excel Web Query object.
To help me narrow down the cause, could you please provide the following details?
- Do you have access to the ServiceNow API documentation for your SSO configuration?
- Which method of SSO does your organization use (e.g., OAuth, SAML)?
- Are you familiar with handling HTTP requests in VBA (using
MSXML2.XMLHTTPor similar)? - Have you tried accessing the ServiceNow API outside of Excel to understand the SSO flow?
- Is there a specific error you encounter when using the existing method or is it more about the process being cumbersome?
In the meantime, please try the following official troubleshooting options which usually resolve issues with basic issues:
The core problem is that the SSO process requires a user to interact with a web page to authenticate, and VBA cannot natively handle this interactive, token-based process.
Step 1: Use the ServiceNow REST API
Since your goal is to import data from ServiceNow, the most modern, secure, and reliable approach is to connect directly to the ServiceNow REST API instead of relying on screen scraping the login page.
- ServiceNow APIs are designed for this exact purpose: fetching structured data programmatically.
- Instead of using your interactive SSO login, you should use API Keys, OAuth 2.0 Client Credentials, or a dedicated Integration User with a standard username/password (which may be excluded from the general SSO mandate) or a refresh token.
Work with your ServiceNow Administrator to set up a dedicated "Integration User" (if allowed by your organization) or configure an OAuth 2.0 Client/Profile that is authorized to fetch the necessary data. This will provide you with a secure token you can pass directly in the VBA request header.
You would use the Microsoft XML, v6.0 (or similar) library in your VBA code to make GET requests to the ServiceNow API endpoints, passing the security token or credentials in the HTTP header.
Step 2: Power Query (Get & Transform)
If the data is simple enough, you might be able to bypass VBA altogether for the import step:
- Power Query (Data Tab > Get Data): Power Query (M Language) is the modern successor to Web Queries and has better handling for authentication, including the ability to connect to certain API endpoints and manage credentials more robustly than VBA.
- While it's better than VBA, it still often struggles with non-standard or highly complex SSO/MFA flows. However, if ServiceNow offers a standard Web API endpoint, Power Query can be configured to use a Web API Key or OAuth token via the advanced editor.
For more details, please refer to Microsoft’s official documentation:
Connecting to external data with Excel Online
I truly hope you understand that the initial steps I suggested may not have completely resolved the issue, as there might still be underlying causes, we haven't uncovered yet. Please know that I’m here with you every step of the way, ready to work together and do everything I can to help troubleshoot and find the best solution.
Please let me know if you have any further questions or if the problem persists after trying these solutions. Thank you for your patience and cooperation.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.