gsimardnet / PowerQueryNet

Run M Language (Power Query Formula Language) from anywhere.
MIT License
189 stars 32 forks source link

Credentials for Rest API services #11

Closed Jordi3Rs closed 5 years ago

Jordi3Rs commented 5 years ago

I am a bit lost searching for information about credentials management. I have understood and experimented the several exemples that are part of the project. In fact I have been able to connect to SQL database through windows account and also through an SQL account. Files and Folders seems to work also well, assuming they are taking my current windows credentials to log into the remote resources that are under the same Domain.

My doubts started using web resources. I have tried a couple of URLs I use in my powerqueries in Excel which are in fact Rest API services. In both cases I use usename/password to authenticate the query but there is no way to make it run in PQNet. I have tried Windows Credential manager, also tags for username and password in the Credentials XML file (as for SQL or OData), but with no success.

I feel I am not doing it correctly but I don't know what else to try.

Any information that can drive me in the use of PQNet for Rest API resources? Thanks Jordi

gsimardnet commented 5 years ago

I haven't made any documentation yet so, like you mention, the best way for now is to look at the samples.

If you are trying to authenticate with basic credentials (Username and Password) to your REST service, I have just added support for this type of autentication for CredentialWeb in the latest version (1.1.2).

Here is a sample of what your credential file should look like:


<Credentials xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Credential xsi:type="CredentialWeb">
    <Url>https://api.myservice.com</Url>
    <Username>GSIMARD</Username>
    <Password>xxxxxxxxxx</Password>
  </Credential>
</Credentials>
Jordi3Rs commented 5 years ago

I have also tested it using the new version and it works for UserName and Password REST Services.

Now I have seen how this is structured in your code, if I need any additional credential support I will pull for a request.

Thanks Jordi