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

Announcements

News and Announcements icon
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,189 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
    946 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 387

#2
timl Profile Picture

timl 340 Super User 2026 Season 1

#3
Vish WR Profile Picture

Vish WR 301

Last 30 days Overall leaderboard