web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Passing Access Tokens ...
Power Apps
Unanswered

Passing Access Tokens in URLs

(0) ShareShare
ReportReport
Posted on by

Hi everybody,

I'm trying to pass an access token to the URL for a GET request to the dataverse API instead of using the header authorization. I have tried appending it as a query parameter like "https://....?access_token=..." but I keep getting a 401 unauthorized error.

Could anyone provide some guidance on the proper way to pass the access token in the URL rather than the header for this API? I would really appreciate any solution to get this working.

Let me know if you have any ideas or examples of constructing the URL with the access token that you know will work with the dataverse API. I'm wondering if I'm missing something simple in how I'm formatting the token in the URL.

Any help is much appreciated!

Thank you!

I have the same question (0)
  • ivan_apps Profile Picture
    2,187 Moderator on at

    Is there a reason you can’t put the access token in the header? As far as I know that’s the only place you can put the access token once you’ve retrieved one. 

  • Shashank Bhide Profile Picture
    942 Moderator on at

    What you're trying is wrong and not how it works, you've to put the token in the header.

     

     var client = new HttpClient
     {
     // See https://docs.microsoft.com/powerapps/developer/data-platform/webapi/compose-http-requests-handle-errors#web-api-url-and-versions
     BaseAddress = new Uri(resource + "/api/data/v9.2/"),
     Timeout = new TimeSpan(0, 2, 0) // Standard two minute timeout on web service calls.
     };
    
     // Default headers for each Web API call.
     // See https://docs.microsoft.com/powerapps/developer/data-platform/webapi/compose-http-requests-handle-errors#http-headers
     HttpRequestHeaders headers = client.DefaultRequestHeaders;
     headers.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken);
     headers.Add("OData-MaxVersion", "4.0");
     headers.Add("OData-Version", "4.0");
     headers.Accept.Add(
     new MediaTypeWithQualityHeaderValue("application/json"));
     #endregion Client configuration
    
     #region Web API call
    
     // Invoke the Web API 'WhoAmI' unbound function.
     // See https://docs.microsoft.com/powerapps/developer/data-platform/webapi/compose-http-requests-handle-errors
     // See https://docs.microsoft.com/powerapps/developer/data-platform/webapi/use-web-api-functions#unbound-functions
     var response = await client.GetAsync("WhoAmI");

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard