Forum Discussion
Unable to Authenticate Anonymous Access OData Feed/API
Hello,
I am working to integrate PowerBI with a vendor solution/API (Cornerstone) and I have the following code to enter into the Advanced Editor:
let
client_id = "",
client_secret = "",
corporation_host = "",
//do not edit section below
base_url = "https://" & corporation_host & ".csod.com/services/api",
token_url = base_url & "/oauth2/token",
odata_url = base_url & "/x/odata/api/views/",
query = [
clientId = client_id,
clientSecret = client_secret,
grantType = "client_credentials",
scope="all"
],
oauthRequest = Json.FromValue(query),
Response = Web.Contents(token_url, [
Content = oauthRequest,
Headers=[#"Content-type" = "application/json",#"Accept" = "application/json"], ManualStatusHandling = {400}
]
),
Parts = Json.Document(Response),
authToken = if (Record.HasFields(Parts, {"error", "error_description"})) then
error Error.Record(Parts[error], Parts[error_description], Parts)
else
"Bearer " & Parts[access_token],
Source=OData.Feed(odata_url,[#"Authorization" = authToken],null),
//end of do not edit section
User_View = Source{[Name="vw_rpt_user",Signature="table"]}[Data]
in
User_View
I have the correct client secret, ID and site host name, and I am experiencing the following errors:
1) After loading the code into Power Query using the Advanced Editor I get this errror:
2) When I try to configure anonymous access from data source settings - I am returned with the error that "we couldn't authneticate with the credentials provided. Please try again"
Am I missing something in my code or did I misconfigure my OAuth client for my data source? I am trying to access a production government instance if that provides any insight in terms of secruity.
3 Replies
- ImkeFCommunity Champion
Hi Anonymous ,
did you debug parts of your code already?
Like for example if a Token is actually returned?- AnonymousNot applicable
Hi! I am just now re-visiting this and yes - i was able to test via postman and a token is returned. However, still no luck from the PowerBI side. All of the scopes have been turned on the from the Cornerstone (vendor) portal for my service account and I didn't see anything wrong with the config of my OAuth application - I've seen on this forum somebody that was encountering the same issues, but the solution that worked for them (turning on all scopes) did not do the trick for me, I've tried different queries and still no luck populating into PowerBI
- ImkeFCommunity Champion
Sorry, no further ideas here.
But often pulling this kind of data via Power Automate into a blob storage first is a good/better alternative.