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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
jordy233
Frequent Visitor

OAUTH2 client credentials token request error 'Bad request'

Hello everyone,

 

I'm facing issues with the oauth2 token request in Power Query. See the query below:

 

 

let
AccessToken = Json.Document(Web.Contents("xxx", 
    [
        Headers=[Accept="application/json", #"Content-Type"="application/x-www-form-urlencoded"],
        Content=Text.ToBinary(
            "grant_type=client_credentials&
            client_id=xxx&
            client_secret=xxx&
            scope=xxx"
        )
    ]))


in
AccessToken

 

 

 

I'm facing the error below:

jordy233_0-1655749768960.png

 

In Postman, I succeeded to get a response with token. 

 

Could anyone provide any help?

1 REPLY 1
Anonymous
Not applicable

Hi @jordy233 ,

Please review the following links which has the similar problem with yours, hope they can help you resolve the problem.

(400) Bad Request using Web.Contents to connect to REST API via Oauth2

There is a similar blog providing details about how to connect to REST API via OAuth2 in Power BI, you can following the instructions in this blog to connect to your data source.

If you still get error, you can use Fiddler to track the process following the guide in this video.

PowerBI DataSource.Error: Web.Contents failed to get contents (400): Bad request

In addition, you can refer the following links to get the token.

Getting Authentication Access Tokens for Microsoft APIs

Accessing API with Oauth2 using M language in Power BI

Best Regards

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.