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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

OAuth 2.0 ROPC issue(Data Connector)

Hi 

 

I have created a data connectors that uses an Oauth 2.0 flow to connect to our cloud environment. I have used the client_id, username and password in the flow, yet while execution it prompts for sign credentials which shouldn't be the case. Based on the document this is a special error when there is something wrong with the data source kind and path. 

 

[DataSource.Kind = "System" , Publish="System.Publish"]
shared System.Contents = Value.ReplaceType(SystemNavTable, type function (url as Uri.Type) as any);

 

// Oauth Data Source Kind description


System = [
Testconnection = (dataSourcePath) => {"System.Contents"},
Authentication = [
OAuth = [
StartLogin=StartLogin,
FinishLogin=FinishLogin,
Refresh=Refresh,
Logout=Logout
]
],
Label = "System Connector"
];

StartLogin = (resourceUrl, state, display) =>
let
authorizeUrl = authorize_uri & "?" & Uri.BuildQueryString([
client_id = client_id,
redirect_uri = redirect_uri,
state = state,
scope = "offline_access " & GetScopeString(scopes, scope_prefix),
response_type = "code",
response_mode = "query",
login = "login"
])
in
[
LoginUri = authorizeUrl,
CallbackUri = redirect_uri,
WindowHeight = 720,
WindowWidth = 1024,
Context = null
];

FinishLogin = (context, callbackUri, state) => //FinishLogin = (context, CallbackUri, state) =>
let
// parse the full callbackUri, and extract the Query string
parts = Uri.Parts(callbackUri)[Query],
// if the query string contains an "error" field, raise an error
// otherwise call TokenMethod to exchange our code for an access_token
result = if (Record.HasFields(parts, {"error", "error_description"})) then
error Error.Record(parts[error], parts[error_description], parts)
else
TokenMethod("authorization_code", "code", parts[code])
in
result;

Refresh = (resourceUrl, refresh_token) => TokenMethod("refresh_token", "refresh_token", refresh_token);

Logout = (token) => logout_uri;

//This is called when StartLogin() is completed and a redirect occurs.
TokenMethod = (grantType, tokenField, code) =>
let
queryString = [
client_id= "passing the client id value",
scope="openid clientid(value) offline_access",
grant_type="password",
//response_type="token",
username="passing the username value",
password="passing the password value!"
],
queryWithCode = Record.AddField(queryString, tokenField, code),

tokenResponse = Web.Contents(token_uri, [
Content = Text.ToBinary(Uri.BuildQueryString(queryWithCode)),
Headers = [
#"Content-type" = "application/x-www-form-urlencoded",
#"Accept" = "application/json"
],
ManualStatusHandling = {400}
]),
body = Json.Document(tokenResponse),
result = if (Record.HasFields(body, {"error", "error_description"})) then
error Error.Record(body[error], body[error_description], body)
else
body
in
result;

 

As you see, I'm passing the username and password but it still redirects me to the login screen(which again according the microsoft doc is an error). Can someone please advise what is wrong with the above code. 

 

 

 

3 REPLIES 3
dearwatson
Continued Contributor
Continued Contributor

Hi @AsfarP1 Did you ever resolve this? Trying to implement OAuth2 ROPC myself right now.
dax
Community Support
Community Support

Hi @Anonymous , 

I am nor familiar with this part, I suggest youcould @ super users in this forum or open a ticket for this porblem.

Best Regards,
Zoe Zhi

Anonymous
Not applicable

Hi Zoe

 

I can't open a support ticket and I'm not sure what do you mean by " I suggest youcould @ super users in this forum". Do you mean I should tag super users?

 

I've been trying to get through this issue from quite a while. I've checked Microsoft documents and also checked third party blogs but none of it has helped. Hoping someone very much familiar with OAuth data connectors can help. 

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.

Top Kudoed Authors