The Invalid Token Type error while trying to connect to the Power BI XMLA endpoint using ADOMD typically implies the underlying issue of authentication. This error condition can arise because of two reasons: either the credentials provided would not satisfy the security requirements for XMLA endpoints, or the ADOMD client is misconfigured. Here are some of the troubleshooting as well as resolution measures:
1. Authentication Type Check
Power BI's XMLA endpoint utilizes Azure Active Directory (AAD) authentication. When authenticating, tokens for the AAD must be used rather than any other methods, such as basic or Windows authentication.
Verify that the user has required permission on the Power BI workspace, such as "Admin" or "Member" access.
2. Update ADOMD.NET Library
Old versions of the ADOMD.NET client library have compatibility problems with current authentication. Get and install the latest Microsoft Analysis Services ADOMD.NET client version.
3. Use the Proper Connection String
To use the XMLA endpoint URL, ensure that your connection string is properly formed.
Data Source=https://yourpowerbiworkspace.xmla.powerbi.com; Initial Catalog=DatasetName
If using a token, add it programmatically to the connection:
If using a token, add it programmatically to the connection:
connection.SessionID = "AAD_TOKEN";
connection.Open();
4. Generate a Valid AAD Token
- Use a tool or code snippet to acquire an Azure Active Directory token. For example, with Python and msal:
from msal import PublicClientApplication
app = PublicClientApplication("CLIENT_ID", authority="https://login.microsoftonline.com/TENANT_ID")
token_response = app.acquire_token_interactive(["https://analysis.windows.net/powerbi/api/.default"])
aad_token = token_response.get("access_token")
5. Checking Connectivity
Connect to the XMLA endpoint through tools, such as SSMS (SQL Server Management Studio). If SSMS connects successfully, the possible problem may be with the ADOMD client setup or the code.
6. Service Principal Enablement
If using service principal authentication, ensure it is enabled on Power BI and has adequate permission within the portal and workspace in Azure.
7. Check Firewall and Network Configurations
Make sure your network allows outgoing communication to Power BI XMLA endpoint URLs. Firewalls or proxies preventing this connection will lead to authentication issues.
Follow these steps, and you should successfully fix the 'Invalid Token Type' glitch and have full access to Power BI's XMLA endpoint.