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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Greg_Deckler
Community Champion
Community Champion

Windows Authentication with Custom Connector

Trying to create a pretty simple custom connector for Power BI. .pq code is listed below and I have attached the .mez file. The idea for the connector is to connect to a folder and pull back all of the files in the folder (CSV files) and allow you to choose which files you want and each becomes its own query. The current problem I have is that my Windows credentials are not associating with my selected folder. So, when I use the connector the following happens:

1. Prompts me for a folder path

2. Prompts me for credentials

3. Errors and tells me I need to provide credentials or "Please specifyhow to connect"

Greg_Deckler_0-1715120780818.png

I'm sure it's something silly and easy but I can't figure it out. 

// This file contains your Data Connector logic
[Version = "1.0.0"]
section TDGTPQM_FolderFile;

TDGTPQM_FolderFile.GetFile = ( filePath as text) as table =>
    let
        output = Csv.Document(File.Contents(filePath),[Delimiter=",", Encoding=1252, QuoteStyle=QuoteStyle.None])
    in
        output;


[DataSource.Kind="TDGTPQM_FolderFile", Publish="TDGTPQM_FolderFile.Publish"]
shared TDGTPQM_FolderFile.Contents = ( folder as text ) =>
    let
        //Credential = Extension.CurrentCredential(),
        files = 
            Table.DuplicateColumn(
                Table.CombineColumns(
                    Table.SelectColumns(
                        Folder.Contents( folder ),
                        { "Name", "Folder Path"}
                    ),
                    { "Folder Path", "Name" }, 
                    Combiner.CombineTextByDelimiter("", QuoteStyle.None), 
                    "Name"
                ),
                "Name",
                "Key"
            ),
        addDataColumn = Table.AddColumn( files, "Data", each TDGTPQM_FolderFile.GetFile([Key])),
        addItemKindColumn = Table.AddColumn( addDataColumn, "ItemKind", each "Table"),
        addItemNameColumn = Table.AddColumn( addItemKindColumn, "ItemName", each "Table"),
        addIsLeafColumn = Table.AddColumn( addItemNameColumn, "IsLeaf", each true),
        Navigation = Table.ToNavigationTable( addIsLeafColumn, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")
    in
        Navigation;

// Data Source Kind description
TDGTPQM_FolderFile = [
    TestConnection = ( dataSourcePath ) => { "TDGTPQM_FolderFile.Contents" },
    Authentication = [
        // Key = [],
        //UsernamePassword = [],
        Windows = [ SupportsAlternateCredentials = true ]
        //Anonymous = []
    ]
];

// Data Source UI publishing description
TDGTPQM_FolderFile.Publish = [
    Beta = true,
    Category = "Other",
    ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
    LearnMoreUrl = "https://powerbi.microsoft.com/",
    SourceImage = TDGTPQM_FolderFile.Icons,
    SourceTypeImage = TDGTPQM_FolderFile.Icons
];

TDGTPQM_FolderFile.Icons = [
    Icon16 = { Extension.Contents("TDGTPQM_FolderFile16.png"), Extension.Contents("TDGTPQM_FolderFile20.png"), Extension.Contents("TDGTPQM_FolderFile24.png"), Extension.Contents("TDGTPQM_FolderFile32.png") },
    Icon32 = { Extension.Contents("TDGTPQM_FolderFile32.png"), Extension.Contents("TDGTPQM_FolderFile40.png"), Extension.Contents("TDGTPQM_FolderFile48.png"), Extension.Contents("TDGTPQM_FolderFile64.png") }
];

Table.ToNavigationTable = (
    table as table,
    keyColumns as list,
    nameColumn as text,
    dataColumn as text,
    itemKindColumn as text,
    itemNameColumn as text,
    isLeafColumn as text
) as table =>
    let
        tableType = Value.Type(table),
        newTableType = Type.AddTableKey(tableType, keyColumns, true) meta 
        [
            NavigationTable.NameColumn = nameColumn, 
            NavigationTable.DataColumn = dataColumn,
            NavigationTable.ItemKindColumn = itemKindColumn, 
            Preview.DelayColumn = itemNameColumn, 
            NavigationTable.IsLeafColumn = isLeafColumn
        ],
        navigationTable = Value.ReplaceType(table, newTableType)
    in
        navigationTable;

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
2 REPLIES 2
Anonymous
Not applicable

Hi @Greg_Deckler ,

Could you please try the following steps and check if can solve your problem?

  • Clear all permissions: Go to File > Options and Settings > Data Source Settings > Global Permissions and click on Clear All Permissions.vyiruanmsft_0-1715161275073.png

     

  • Adjust the data extension security settings: In Power BI Desktop, select File > Options and settings > Options > Security. Under Data Extensions, select (Not Recommended) Allow any extension to load without validation or warning. Then, restart Power BI Desktop.vyiruanmsft_1-1715161321444.png
  • Restart the computer: Solved: Custom Connector - anonymous Authentication issue 

Best Regards

@Anonymous Thanks but did not work. My fear is that Folder.Contents is not supported: Custom connector for proprietary file type - Microsoft Fabric Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.