Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ochaoui
Frequent Visitor

Custom connector : pass UI values to StartLogin function

Hi Folks,

 

I am developing a custom connector where the user write down on the UI :

- the API URL

- the client_id

-the client_secret

ochaoui_0-1637765484023.png

 

I would like to know how to pass the client_id and client_secret to my  StartLogin and  FinishLogin ?

Thanks in advance.

 

Regards,

1 ACCEPTED SOLUTION

Hi @v-rzhou-msft ,

 

Thanks for your reply but it does not reply to my problem.

 

I found the solution to get those values :

StartLogin = (clientApplication, dataSourcePath, state, display) =>
    let
      authorizeUrl = AUTHORIZE_URI & "?" & Uri.BuildQueryString([
        response_type = "code",
        client_id = Json.Document(dataSourcePath)[client_id],  
        redirect_uri = REDIRECT_URI,
        state1 = state,
        scope = GetScopeString(SCOPES, SCOPE_PREFIX)
      ])
    in
      [
        LoginUri = authorizeUrl,
        CallbackUri = REDIRECT_URI,
        WindowHeight = WINDOW_HEIGHT,
        WindowWidth = WINDOW_WIDTH,
        Context = null
      ];

You need to parse the "dataSourcePath" variable.

 

Regards,

View solution in original post

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @ochaoui 

1. Create a Data Source definition

//
// Data Source definition
//
GithubSample = [
    Authentication = [
        OAuth = [
            StartLogin = StartLogin,
            FinishLogin = FinishLogin
        ]
    ],
    Label = Extension.LoadString("DataSourceLabel")
];

2. Provide details so the M engine can start the OAuth flow.

The following code snippet describes how to implement a StartLogin function to start the login flow. 

StartLogin = (resourceUrl, state, display) =>
        let
            AuthorizeUrl = "https://github.com/login/oauth/authorize?" & Uri.BuildQueryString([
                client_id = client_id,
                scope = "user, repo",
                state = state,
                redirect_uri = redirect_uri])
        in
            [
                LoginUri = AuthorizeUrl,
                CallbackUri = redirect_uri,
                WindowHeight = windowHeight,
                WindowWidth = windowWidth,
                Context = null
            ];

For more details you may refer to this offical blog: GitHub Connector Sample

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @v-rzhou-msft ,

 

Thanks for your reply but it does not reply to my problem.

 

I found the solution to get those values :

StartLogin = (clientApplication, dataSourcePath, state, display) =>
    let
      authorizeUrl = AUTHORIZE_URI & "?" & Uri.BuildQueryString([
        response_type = "code",
        client_id = Json.Document(dataSourcePath)[client_id],  
        redirect_uri = REDIRECT_URI,
        state1 = state,
        scope = GetScopeString(SCOPES, SCOPE_PREFIX)
      ])
    in
      [
        LoginUri = authorizeUrl,
        CallbackUri = REDIRECT_URI,
        WindowHeight = WINDOW_HEIGHT,
        WindowWidth = WINDOW_WIDTH,
        Context = null
      ];

You need to parse the "dataSourcePath" variable.

 

Regards,

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.