We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register 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.
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 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 10 | |
| 8 | |
| 7 | |
| 7 | |
| 5 |