Join 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!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi Team,
We've Smile CDR fhir server that supports oauth2. We're trying to connect to it using power bi, for this we're creating custom connector. We've added power bi as a client in Smile CDR. In the code we're passing every details however, we're getting 404 error. I've shared the code and screenshots below.
Code:
// This file contains your Data Connector logic
section SmileCDR;
[DataSource.Kind="SmileCDR", Publish="SmileCDR.Publish"]
shared SmileCDR.Contents = (optional message as text) =>
let
_message = if (message <> null) then message else "(no message)",
a = "Hello from SmileCDR: " & _message
in
a;
// Data Source Kind description
SmileCDR = [
Authentication = [
OAuth = [
StartLogin = StartLogin,
FinishLogin = FinishLogin
]
],
Label = Extension.LoadString("DataSourceLabel")
];
StartLogin = (resourceUrl, state, display) =>
let
AuthorizeUrl = "http://xx.xx.xx.xx/issuer/oauth/authorize" & Uri.BuildQueryString([
client_id = "client_id",
scope = "scope",
state = state,
redirect_uri = " https://oauth.powerbi.com/views/oauthredirect.html"])
in
[
LoginUri = "http://xx.xx.xx.xx/issuer/oauth/authorize",
CallbackUri = " https://oauth.powerbi.com/views/oauthredirect.html",
WindowHeight = 800,
WindowWidth = 800,
Context = null
];
FinishLogin = (context, callbackUri, state) =>
let
Parts = Uri.Parts(callbackUri)[Query]
in
TokenMethod(Parts[code]);
TokenMethod = (code) =>
let
Response = Web.Contents("http://xx.xx.xx.xx/issuer/oauth/token", [
Content = Text.ToBinary(Uri.BuildQueryString([
client_id = "client_id",
client_secret = "client_secret",
code = code,
redirect_uri = " https://oauth.powerbi.com/views/oauthredirect.html"])),
Headers=[#"Content-type" = "application/x-www-form-urlencoded",#"Accept" = "application/json"]]),
Parts = Json.Document(Response)
in
Parts;
// Data Source UI publishing description
SmileCDR.Publish = [
Beta = true,
Category = "Other",
ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
LearnMoreUrl = "https://powerbi.microsoft.com/",
SourceImage = SmileCDR.Icons,
SourceTypeImage = SmileCDR.Icons
];
SmileCDR.Icons = [
Icon16 = { Extension.Contents("SmileCDR16.png"), Extension.Contents("SmileCDR20.png"), Extension.Contents("SmileCDR24.png"), Extension.Contents("SmileCDR32.png") },
Icon32 = { Extension.Contents("SmileCDR32.png"), Extension.Contents("SmileCDR40.png"), Extension.Contents("SmileCDR48.png"), Extension.Contents("SmileCDR64.png") }
];
After running the code we're able to reach to signin page of Smile CDR. On sign in page we're passing the credentials and then we're getting 404 error as displayed in the screenshot.
Could anyone provide any suggestions?
1st
2nd
3rd
Hi @vsingh23
See if this blog is helpful: Building a custom connector for Power BI that supports OAuth2 to visualize my wellness data - Jussi ...
Also, in this official document, it has Refresh and Logout section after FinishLogin section while your codes don't. Not sure if this is the cause.
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 10 | |
| 9 | |
| 6 | |
| 5 | |
| 3 |