Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I am trying to create an OAauth 2.0 connector using Power Query SDK. A few issues I am facing.
AppTesting.PagedTable is not defined and when I run the project I get an error "The export AppTesting.Contents was exported multiple times."
It looks like there is a 'new' sdk for 'Visual Studio Code' That is what I attempted to use after I failed to get the connector working with VS 2019 and the SKD. Ill post that below (I just need one working)
https://learn.microsoft.com/en-us/power-query/samples/github/readme
https://learn.microsoft.com/en-us/power-query/handling-authentication
I have a few other projects, one I followed this tutorial and can post the code but I also receive other errors https://jussiroine.com/2019/02/building-a-custom-connector-for-power-bi-that-supports-oauth2-to-visu...
Non of the tutorials I am able to get working
// This file contains your Data Connector logic
[Version = "1.0.0"]
section AppTesting;
[DataSource.Kind="AppTesting", Publish="AppTesting.UI"]
shared AppTesting.Contents = Value.ReplaceType(AppTesting.Contents, type function (url as Uri.Type) as any);
// Error cant find the name AppTesting.PagedTable
[DataSource.Kind="AppTesting"]
shared AppTesting.PagedTable.PagedTable = Value.ReplaceType(AppTesting.PagedTable, type function (url as Uri.Type) as nullable table);
// Data Source Kind description
AppTesting = [
Authentication = [
OAuth = [
StartLogin = StartLogin,
FinishLogin = FinishLogin
]
]
];
StartLogin = (resourceUrl, state, display) =>
let
AuthorizeUrl = "https://xxxurl.com/oauth/v1/authorize" & Uri.BuildQueryString([
client_id = "xxxxxxx",
client_secret = "xxxxxx",
scope = "user, repo",
state = state,
redirect_uri = "https://oauth.powerbi.com/views/oauthredirect.html"])
in
[
LoginUri = AuthorizeUrl,
CallbackUri = "https://oauth.powerbi.com/views/oauthredirect.html",
WindowHeight = 720,
WindowWidth = 1024,
Context = null
];
FinishLogin = (context, callbackUri, state) =>
let
Parts = Uri.Parts(callbackUri)[Query]
in
TokenMethod(Parts[code]);
TokenMethod = (code) =>
let
Response = Web.Contents("https://xxxurl.com/oauth/v1/token", [
Content = Text.ToBinary(Uri.BuildQueryString([
client_id = @client_id,
client_secret = @client_secret,
code = code,
redirect_uri = @redirect_uri])),
Headers=[#"Content-type" = "application/x-www-form-urlencoded",#"Accept" = "application/json"]]),
Parts = Json.Document(Response)
in
Parts;
// Data Source UI publishing description
AppTesting.Publish = [
Beta = true,
Category = "Other",
ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
LearnMoreUrl = "https://powerbi.microsoft.com/",
SourceImage = AppTesting.Icons,
SourceTypeImage = AppTesting.Icons
];
AppTesting.Icons = [
Icon16 = { Extension.Contents("AppTesting16.png"), Extension.Contents("AppTesting20.png"), Extension.Contents("AppTesting24.png"), Extension.Contents("AppTesting32.png") },
Icon32 = { Extension.Contents("AppTesting32.png"), Extension.Contents("AppTesting40.png"), Extension.Contents("AppTesting48.png"), Extension.Contents("AppTesting64.png") }
];
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.