Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
pgarman
New Member

OAuth for Power BI Custom Connector issues

Hello all!

 

I am hoping that someone has a solution or guidance.  The documentation for using OAuth in custom connectors for Power BI leaves a lot to be desired.....

 

Here is the experiene I am trying to create when setting up the connector in Power BI Desktop.  I am new to M Language, so I'm having trouble understanding the standard OAuth flow.

 

  1. When setting up the connector, the user enters the base url for the data source, a client ID, and client Secret.
  2. These variables get passed into the OAuth flow for the connector to retrieve an API Token that can be appended to the header of REST API requests.  The token is generated once, and reused for each 'page' of data retrieved with the request (my data source returns a max of 50 records with each request, so pagination will be necessary).

Where I am having an issue is that my data source doesn't follow the prescribed path for OAuth in Power BI connectors - the API Token is generated with a POST to {client_id}:{client_secret}@{baseurl}/rest/oath/token and a body with grant_type = client_credentials.  This API call returns a JSON with access_token that can then be stored as a variable applied in the header.

 

Here is a screenshot from Postman of a successful token request:

 

Screenshot 2024-03-12 at 2.44.02 PM.png

 

Basically, it does not seem like I need the StartLogin section, or I'm not sure what to put in that section since there is no authorization URL, just a token request URL.

 

Any guidance on this would be GREATLY appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @pgarman ,

 

Based on my understanding and research, your approach of generating a Bearer Token via OAuth to access certain APIs seems to support an “anonymous” connection mode. However, it’s important to note that this Bearer Token is dynamic and typically has a validity period of one hour. If you wish to implement a method for dynamically generating the Bearer Token, you’ll need to use M query to obtain the latest Bearer Token in real-time during each data refresh. You can refer to the following links to determine if they provide any helpful insights:

curatedsql.com

www.linkedin.com

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @pgarman ,

 

Based on my understanding and research, your approach of generating a Bearer Token via OAuth to access certain APIs seems to support an “anonymous” connection mode. However, it’s important to note that this Bearer Token is dynamic and typically has a validity period of one hour. If you wish to implement a method for dynamically generating the Bearer Token, you’ll need to use M query to obtain the latest Bearer Token in real-time during each data refresh. You can refer to the following links to determine if they provide any helpful insights:

curatedsql.com

www.linkedin.com

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

pgarman
New Member

I have set up a connector using Anonymous rather than OAuth, but it is not reliable - about 25% of the initial connections or data refreshes return an error from Power BI Desktop that the credentials could not be authenticated.

 

I suspect this might be due to the connector requesting a new token with each 'page' of records, but it's hard to see what is actually happening since Power BI does not give the actual error message from the data source being queried.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.