Closed rfthomsen closed 5 years ago
Hi @rfthomsen I appreciate your feedback! I have spent hours trying to make a workaround for this. It seems that Power BI services is somewhat restricted or limited in th OAuth feature set for custom connectors. The problem occurs with Facebook specifically and maybe others. When I do exactly the same on a Google service I have no issues with OAuth thru the on-premise gateway (Personal and Enterprise) Maybe I have missed something. If you have any ideas - they are really welcome :)
Interesting! It looks like the authentication request is correctly routed to Facebook's OAuth dialog, and you can grant the permissions requested, only the response (including the auth token) doesn't seem to be sent back to Power BI correctly.
I assume you've already tried authenticating with different versions of the Graph API (3.0, 3.1, etc.)? I tried fiddling around with the settings in the connector a bit, but as yet no luck. I'll let you know if I make any progress.
@rfthomsen I did indeed try different versions of the Graph API. I suspected af bug in the online OAuth flow, so I actually debugged every line of javascript code in the BI Services flow and - at the time - concluded the issue lay within receiving and storing the token/passing the token back to the custom connector. As I recall something was hardcoded. But since it was a blackbox test/debug it's a bit limited what to conclude. I wrote to the MS connector team but never got any feedback on this subject. I did have luck with other dialogues though.
@mbilling In that case it's probably unlikely that I'll have better luck than you ;)
I did try looking into why the tokens do seem to be processed correctly in the case of the Facebook connector (for personal profiles) bundled with Power BI, but not in this connector (in this case I'm looking at the Instagram connector, but I believe the flow is the same). Since I'm no expert in OAuth at all, I started by just examining the redirect chains, which go like this:
1
Bundled connector:
https://preview.powerbi.com/views/oauthredirect.html?login_uri=https%3A%2F%2Fwww.facebook.com%2Fv2.8%2Fdialog%2Foauth%3Fstate%3Dapp.powerbi.com%26display%3D%26client_id%3D496882327120322%26redirect_uri%3Dhttps%253A%252F%252Fpreview.powerbi.com%252Fviews%252Foauthredirect.html%26scope%3Duser_likes%252Buser_friends%252Bread_insights%252Bemail%252Buser_status%252Bpublic_profile%252Buser_about_me%252Buser_posts%26response_type%3Dtoken&redirect_targeturi=https%3A%2F%2Fapp.powerbi.com
This connector:
https://preview.powerbi.com/views/oauthredirect.html?login_uri=https%3A%2F%2Fwww.facebook.com%2Fv2.12%2Fdialog%2Foauth%3Fclient_id%3D422392478202997%26redirect_uri%3Dhttps%253A%252F%252Foauth.powerbi.com%252Fviews%252Foauthredirect.html%26state%3Dapp.powerbi.com%26scope%3Dmanage_pages%2520instagram_basic%2520instagram_manage_insights%26response_type%3Dcode&redirect_targeturi=https%3A%2F%2Fapp.powerbi.com
2
Bundled connector:
https://www.facebook.com/v2.8/dialog/oauth?state=app.powerbi.com&display=&client_id=496882327120322&redirect_uri=https%3A%2F%2Fpreview.powerbi.com%2Fviews%2Foauthredirect.html&scope=user_likes%2Buser_friends%2Bread_insights%2Bemail%2Buser_status%2Bpublic_profile%2Buser_about_me%2Buser_posts&response_type=token
This connector:
https://www.facebook.com/v2.12/dialog/oauth?client_id=422392478202997&redirect_uri=https%3A%2F%2Foauth.powerbi.com%2Fviews%2Foauthredirect.html&state=app.powerbi.com&scope=manage_pages%20instagram_basic%20instagram_manage_insights&response_type=code
3
Bundled connector:
https://preview.powerbi.com/views/oauthredirect.html?#access_token=[redacted]&data_access_expiration_time=1576133360&expires_in=4240&state=app.powerbi.com
This connector:
https://oauth.powerbi.com/views/oauthredirect.html?code=[redacted]&state=app.powerbi.com#_=_
4
Bundled connector:
https://app.powerbi.com/providers/oauthRedirectReceiver#access_token=EAAHD6W6aacIBAAo5KSD0Op6X2ZCPHOi5XBM4o4PZAqgINUKcKabR9o6DNMX6LqPDH6VL1dJGmVxL5bWp0SzGPm7Y4pYebZAZCpBAWa1DfT4VxL6r6BivLybZC4cVS91jAWRR73sdQr0UZCJdwHtqAI41K187NY59paEIghsJBwYb1qyOJY5PmHZBV8oIAgBCGAZD&data_access_expiration_time=1576133360&expires_in=4240&state=app.powerbi.com
This connector: (flow ends here, window closes before oauthRedirectReceiver)
Scopes and client IDs aside, the main difference to me appears to be that the bundled connector uses a parameter response_type=token
in step 2, while this connector sends response_type=code
. Out of curiosity I tried intercepting the OAuth flow of the Instagram connector and substituting in the token
parameter, which actually appears to work out smoothly -- the flow completes and Power BI apparently saves the token.
Unfortunately this breaks down when trying to actually refresh with the new credentials, which gives this error message:
Something went wrong There was an error in the data gateway. Please try again later or contact support. If you contact support, please provide these details. Underlying error message: Object reference not set to an instance of an object. Table: Instagram Page Insights. DM_ErrorDetailNameCode_UnderlyingHResult: -2147467261 Cluster URI: WABI-NORTH-EUROPE-redirect.analysis.windows.net Activity ID: 993d3e78-554d-41ee-9750-3d07f3922d33 Request ID: 10cffa2c-0e85-ce38-229f-1f7fddfe9fe9 Time: 2019-09-13 06:59:13Z
So it's possible this is a dead end after all. But I thought I'd share my investigation either way.
@rfthomsen No, it's NOT a dead end. :) I was actually investigation the same OAuth flow as you did. You pointing out that a bundled connector used the response_type=token as opposed to response_type=code made me immediately realize that this could be the reason for it failing in powerbi.com Not that the existing flow I used was wrong, but only that powerbi.com may have some undocumented "features" - as I suspected.
I managed to make a build of the connector that works :) I'll push it later today and put a working version on https://www.scitylana.com/connectors
Thanks for the http inspection log :) This will make a lot of users og the connectors really happy!
@rfthomsen Maybe you want to be beta tester now? Write me in the chat on Scitylana.com
Fixed and released
Hi @mbilling
This project is brilliant in its simplicity, and I'm impressed at how well the connectors work in Power BI Desktop. On the other hand, I have not yet had luck getting the connectors to work in the Power BI Service via the On-premises gateway (personal mode).
I have added the custom connector to my gateway, and it appears to be recognised when looking at the data source setup in the Service. However, when attempting to configure the connector (set up credentials), the OAuth window appears to open and immediately close. No error message of any kind, but also no authentication screen nor any credentials being saved. The behaviour is exactly the same between the Facebook and Instagram connectors.
Have you by any chance experienced this before, and/or do you have any guidance on getting the connectors to work in the Service? Thus far I've been using the ready-made connectors from SCITYLANA, but I am of course also willing to try setting up my own client if needed.
Thanks for your great work!