Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Custom Data Connector Credential Check Failing - Username/Password generates a token

The REST API I'm querying requires me to login with a username/password and it will return a token, that token then has to be added to the header as x-redlock-auth then the endpoints can be queried.

 

Without the navigator PowerBI desktop won't allow me past the credtials section, with the navigator it's prompting when trying to load my table.

 

I've tried adding my own login section:

 

 

Prisma = [
    TestConnection = (dataSourcePath) => { "Prisma.login" },
    Authentication = [ 
        UsernamePassword = [
            UsernameLabel = "Prisma API User",
            PasswordLabel = "Prisma API Password"
            
        ]
    ],
    Label = "Prisma Data Connector"
];

 

 

This logs in or returns null:

 

 

shared Prisma.login = () =>
    let
        loginPayload = [
            username = Extension.CurrentCredential()[Username],
            password = Extension.CurrentCredential()[Password]
        ],

        responseLogin = Web.Contents("https://api3.prismacloud.io", [
            RelativePath = "/login",
            Headers = [#"Content-Type" = "application/json"],
            Content = Json.FromValue(loginPayload),
            ManualCredentials = true
        ]),

        token = Json.Document(responseLogin)[token]
    in 
        token;

 

 

 I also tried spltting out the login path, however the remote API will return an error unless the crecentials are presented in the way above.

 

My alert function, calls web.contents with:

 

 

        response = Web.Contents(url, [ 
            RelativePath = path,
            Headers = [
                #"Content-Type" = "application/json",
                #"x-redlock-auth" = token
            ],
            Content = payLoad,
            ManualCredentials = true
         ]),   

 

 

 

but the url is the same:

 

 

a = GetAllPages("https://api3.prismacloud.io", "/v2/alert", token, Text.ToBinary(alertPayload))

 

 

Any ideas what it's upset about?

2 Replies