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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Greg_Deckler
Super User
Super User

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;

 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

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

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

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


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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