403 Forbidden when trying to download

Hello,
Please help can’t download.

C#

var client = new HttpClient();
client.BaseAddress = new Uri( "https://api.sketchfab.com" );

var request = new HttpRequestMessage( HttpMethod.Get, $"/v3/models/{uid}/download" );

var keyValues = new List<KeyValuePair<string, string>>();
keyValues.Add( new KeyValuePair<string, string>( "Authorization", "Bearer " + accessToken ) );

request.Content = new FormUrlEncodedContent( keyValues );

var response = await client.SendAsync( request );
var result = await response.Content.ReadAsStringAsync();

Getting the error:

403 Forbidden

{Server: CloudFront
Date: Fri, 16 Jul 2021 15:19:45 GMT
Connection: close
X-Cache: Error from cloudfront
Via: 1.1 055d899361491602a9ef1eb0cdc5e337.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: FRA50-C1
X-Amz-Cf-Id: O20y5DsasLOG0b-b_REW1X9oltzx7_FnWY_TLegLz7ItLq_3xMrrmA==
}

Hi,

I don’t know C#, but by reading your code it seems you are encoding the Authorization string in “url content”, whereas it should be sent as an HTTP header.

PA

Hi, thanks for the answer.
Yes, you are right. Already found it. Fixed code:

var client = new HttpClient();
client.BaseAddress = new Uri( "https://api.sketchfab.com" );

var request = new HttpRequestMessage( HttpMethod.Get, $"/v3/models/{sketchfabUID}/download" );
request.Headers.Add( "Authorization", "Bearer " + accessToken );

var response = await client.SendAsync( request );
var result = await response.Content.ReadAsStringAsync();