Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin 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.
Hi All,
i'm trying to implement the OAuth2 authentication in a custom connector
the first time i run the connector it asks for username and password and then it asks for the authorization from the registered app, the second time i rerun the connector i'm not asked anymore the username and password but i'm asked only to approve the authorization for the registered app
how can i do to force the connector to ask me for username and password everytime i run the connector?
this is the code i user
demo = [
TestConnection = (dataSourcePath) => {"demo.Contents", dataSourcePath},
Authentication = [
OAuth = [
StartLogin = StartLogin,
FinishLogin = FinishLogin,
Label = Extension.LoadString("DataSourceLabel")
]
]
// Label = Extension.LoadString("DataSourceLabel")
];
StartLogin = (resourceUrl, state, display) =>
let
AuthorizeUrl = "https://[servername]/[tenant]/as/authorization.oauth2?" & Uri.BuildQueryString([
client_id = client_id,
response_type = "code",
// state = state,
redirect_uri = redirect_uri])
in
[
LoginUri = AuthorizeUrl,
CallbackUri = redirect_uri,
WindowHeight = windowHeight,
WindowWidth = windowWidth,
Context = null
];
FinishLogin = (context, callbackUri, state) =>
let
Parts = Uri.Parts(callbackUri)[Query]
in
TokenMethod(Parts[code]);
TokenMethod = (code) =>
let
Response = Web.Contents(" https://[servername]/[tenant]/as/token.oauth2", [
Content = Text.ToBinary(Uri.BuildQueryString([
client_id = client_id,
client_secret = client_secret,
code = code,
grant_type = "authorization_code",
redirect_uri = redirect_uri])),
IsRetry = true,
Headers=[#"Content-type" = "application/x-www-form-urlencoded",#"Accept" = "application/json"]]),
Parts = Json.Document(Response)
in
Parts;
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.