This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreJoin 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
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.
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
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.
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 4 |