Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. 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.
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.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |