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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Create a mutable global variable in M language

Hi, community, 

I'm working on a custom connector that needs to authenticate before data representation is done, and to do this I don't want to hardcode the auth credentials in my source code. 

 

So, I declared a global list variable named

 

config = {"a"};

 

 

and in the shared MyCustomConnector.Contents function, I'm doing a List.ReplaceValue on item "a" in the list above.

 

shared MyCustomConnector.Contents = (BaseUrl as text, ClientId as text) => 
List.ReplaceValue(config, "a", BaseUrl, Replacer.ReplaceText);

 

 

so in my StartLogin function, I can just call the config by index like this.

 

//Start Login
StartLogin = (resourceUrl, state, display) =>
    let

        AuthorizeUrl ="https://"&Text.From(config{0})&"/oauth/authorize?" & Uri.BuildQueryString(
            [
                client_id = "11",
                response_type="code",
                state = state,
                redirect_uri = redirect_uri
            ]
        )
    in
        [
            LoginUri = AuthorizeUrl,
            CallbackUri = redirect_uri,
            WindowHeight = windowHeight,
            WindowWidth = windowWidth,
            Context = null
        ];

 

 

But it appears that, the List.ReplaceValue is not being executed because whenever I try to set credential for authentication, "a" is being passed into the URL. 

 

Any help will be much appreciated

1 REPLY 1
lbendlin
Super User
Super User

Please read Ben Gribaudo's primer again.

 

Have a look at the meta data section too.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors
Top Kudoed Authors