migueesc123 / PowerBIRESTAPI

A Microsoft Power BI Data Connector or Power Query Connector for the Power BI REST API
MIT License
234 stars 74 forks source link

Connector for GGCH Endpoint #68

Closed johnlabonte closed 3 years ago

johnlabonte commented 3 years ago

Hi,

I modified your code to direct to the GCCH endpoints (I am on the special gov cloud version of PowerBI).

I'm honestly not familiar with how to use github, so please let me know if I did anything wrong, or not the way you wanted. I created a new Branch (GCCH), and edited all relevant connection information and titles from "Power BI" to "Power BI GCCH".

Please let me if I need to correct anything, thanks for this great code!

johnlabonte commented 3 years ago

Well I think I am proving how I don't know how to use github, I just tried to push my branch and obviously I don't have access. How would you like me to maintain this GCCH variant of your code? Should I request access to create a GCCH branch, or should I just clone and host on my own account?

migueesc123 commented 3 years ago

hey! The best thing would be for you to fork the repo and then create a pull request from your fork with your changes. That would trigger a merge to the master of this repo.

In order for this connector to work for the GCC and other clouds then we'll need the resourceUri for that GCC and then set a switch environment. If you happen to have that and it's working for you, I'll be happy to add it. I don't have a tenant under the GCC, so I can't really test it and I don't think that we have anyone else to give it a try, but as long as you tell us that it's working then that's good enough.

Best!

johnlabonte commented 3 years ago

Hi @migueesc123 , sorry just seeing this now after I just submitted that pull request.

I embedded the different Uri and other urls for each tenant in the updated code. If you would rather embed these into a single connector, with some type of selector for environment that would be really neat, and much cleaner!

I have no idea how to create something that fancy, but if you need those urls for each connection type, I'm happy to provide them!

migueesc123 commented 3 years ago

Could you please post the URL for the cloud environments that you can test?

johnlabonte commented 3 years ago

Here are the changes I made for each variant. Is that switch documentation for the connector in the MS docs? I'll see if I can figure it out as well.

GCC redirect_uri = "https://preview.powerbi.com/views/oauthredirect.html"; token_uri = "https://login.microsoftonline.com/common/oauth2/token"; authorize_uri = "https://login.microsoftonline.com/common/oauth2/authorize"; logout_uri = "https://login.microsoftonline.com/logout.srf"; resourceUri = "https://analysis.usgovcloudapi.net/powerbi/api"; Also find/replace https://api.powerbi.com with https://api.powerbigov.us

GCCH redirect_uri = "https://preview.powerbi.com/views/oauthredirect.html"; token_uri = "https://login.microsoftonline.us/common/oauth2/token"; authorize_uri = "https://login.microsoftonline.us/common/oauth2/authorize"; logout_uri = "https://login.microsoftonline.us/logout.srf"; resourceUri = "https://high.analysis.usgovcloudapi.net/powerbi/api"; Also find/replace https://api.powerbi.com with https://api.high.powerbigov.us

DoD redirect_uri = "https://preview.powerbi.com/views/oauthredirect.html"; token_uri = "https://login.microsoftonline.us/common/oauth2/token"; authorize_uri = "https://login.microsoftonline.us/common/oauth2/authorize"; logout_uri = "https://login.microsoftonline.us/logout.srf"; resourceUri = "https://mil.analysis.usgovcloudapi.net/powerbi/api"; Also find/replace https://api.powerbi.com with https://api.mil.powerbigov.us

Germany DE redirect_uri = "https://preview.powerbi.de/views/oauthredirect.html"; token_uri = "https://login.microsoftonline.de/common/oauth2/token"; authorize_uri = "https://login.microsoftonline.de/common/oauth2/authorize"; logout_uri = "https://login.microsoftonline.de/logout.srf"; resourceUri = "https://analysis.cloudapi.de/powerbi/api"; Also find/replace https://api.powerbi.com with https://api.powerbi.de/

China CN redirect_uri = "https://preview.powerbi.cn/views/oauthredirect.html"; token_uri = "https://login.chinacloudapi.cn/common/oauth2/token"; authorize_uri = "https://login.chinacloudapi.cn/common/oauth2/authorize"; logout_uri = "https://login.chinacloudapi.cn/logout.srf"; resourceUri = "https://analysis.chinacloudapi.cn/powerbi/api"; Also find/replace https://api.powerbi.com with https://api.powerbi.cn/

migueesc123 commented 3 years ago

Hey @jlabjlab you only have access to the GCCH cloud, correct?

johnlabonte commented 3 years ago

Yes I only have access to GCCH

migueesc123 commented 3 years ago

I'll add support to that one so you can give it a try. Hopefully, I'll have some time for it over the weekend.

migueesc123 commented 3 years ago

Hey @jlabjlab ! Could you please give the file below a try? Make sure to unzip it and then place the mez file in your custom connectors folder. Power BI API.zip

migueesc123 commented 3 years ago

Just realized that I added support to GCC and not GCCH. This one should provide support to GCCH Power BI API.zip

johnlabonte commented 3 years ago

it didnt work, it doesnt look like all instances of https://api.powerbi.com were replaced with https://api.high.powerbigov.us

migueesc123 commented 3 years ago

Did you try the last one? What error did you get? Could you check what api call did Power BI make to the API using something like Fiddler?

The way it's implemented doesn't require a "find and replace" as you suggest. It tries to do an internal discovery based on the authenticated user.

johnlabonte commented 3 years ago

It failed because it was trying to authenticate via https://api.powerbi.com not https://api.high.powerbigov.us. I can see this in the error message when trying to select any of the queries (admin or non admin ones)

Unfortunately I cannot run Fiddler on this computer that uses the GCCH connection.

Error is web.contents failed to get contents from 'https://api.powerbi.com/v1.0/myorg [...]'

If it was connecting via the correct GCCH url, I would expect the error message to be web.contents failed to get contents from 'https://api.high.powerbigov.us/v1.0/myorg [...]'

migueesc123 commented 3 years ago

Not what I was expecting. Unfortunately, I don't have a way to troubleshoot this. The version of the connector that you're seeing follows the documentation from Microsoft on how these sort of connectors handle the environment variable. There are other methods, but they'd break the connector or how it's setup at the moment.

The best that I can suggest at this time is to fork our repo and do the find-replace that you suggest.

Hopefully if Microsoft ever picks up this connector we'll be able to address this. At the moment, we don't really have any methods to test, validate or troubleshoot anything outside the public cloud.

johnlabonte commented 3 years ago

Is it possible instead to add a drop down menu at the beginning that asks the user to identify which cloud version they want to connect to, which in turn will set all of these connection strings

migueesc123 commented 3 years ago

That's basically the fix that I'm mentioning that would break all the connections from previous versions of the connector. The main issue is that we can't test things out even if we wanted to as neither of us has access to any of these clouds to fully validate the connector.

johnlabonte commented 3 years ago

Okay. Well at least I have a version on my GitHub complied with those changes if anyone needs the non commerical version