This might be a long shot, but I'm using the MYOB Business API which has the same OAuth authorization flow as the LinkedIn API - 3-legged - and am planning on making queries to it through Excel, most likely power query.
The big issue with this is obviously dealing with the sending and receiving of the code=
, access_token
and refresh_token
. Most of the searches I've done relating to using Power Query and OAuth seem to only deal with username and password OAuth and not the authorization flow, shown here https://developer.indeed.com/docs/authorization/3-legged-oauth.
I'm curious if there is Power Query M Language code out there that I haven't come across or if I have to go the route of building an OData Feed (or another method?) on top of the API so that it can be queried in Excel?
Any help or further direction would be appreciated.
I should also note they have a website containing their Postman collection using different languages here; https://accountrightapi.myob.cloud/?version=latest#f2b93dfa-803f-44b9-8a07-756874494227
CodePudding user response:
The short answer for Excel is: No, but Asterisk.
Excel Power Query
doesn't supportcustom connectors
(as of2022-02-07
)- To securely use
Auth2 flow
, it requires acustom connector
- There is some built in support, if the connector supports it. ( Like Web or OData)
Here's a summarized version of Chris Web
. (He's a Power Query Wizard) Connecting To REST APIs With OAuth2 Authentication In Power Query/Power BI @ blog.crossjoin.co.uk
the definitive, Microsoft-endorsed answer to this question is: If want to connect from
Power BI
to aREST API
that usesOAuth2 authentication
then you need to build a custom connector.
You can use
OAuth2 credential flow
in regular Power Query queries without needing a custom connector.
this is not recommended: it’s not secure and it’s not reliable. In particular, hard-coding usernames/passwords or client ids/client secrets in your M code is a really bad idea
The only exception is that you can connect to some
APIs
that useAAD authentication
using the built-inweb
orOData connectors
To use a
custom connector
in thePower BI Service
, it requires anon-premises gateway
How to implement
OAuth2 flow
Creating a Custom Connector
Using built-in
OAuth2
flow using withAzure Active Directory
using theWeb
andOData
connectors