1

I'm currently writing a client for the google photos api. I created an oauth2 key with the postman feature "get new access token" which works fine. I've got the access token that I use in my c# code.

I keep getting the following message, even if I post with correct headers.

{ "code": 16, "message": "Authentication session is not defined." }

Here you can see my settings: https://i.stack.imgur.com/AfSQ7.jpg

I hope you can help me out.

var HttpClient = new HttpClient();
HttpClient.DefaultRequestHeaders.Add("X-Goog-Upload-File-Name", "test.jpg");
HttpClient.DefaultRequestHeaders.Add("X-Goog-Upload-Protocol", "raw");
HttpClient.DefaultRequestHeaders.Add("Authorization", "Bearer MY_BEARER_TOKEN");

var content = new ByteArrayContent(image.FileContent);

content.Headers.ContentType = new MediaTypeHeaderValue(MediaTypeNames.Application.Octet);
var response = await HttpClient.PostAsync("https://photoslibrary.googleapis.com/v1/uploads", content);

content.Dispose();

return await response.Content.ReadAsStringAsync();
jowiz
  • 11
  • 2

1 Answers1

0

Looking at the scope in the provided image, it looks like you're using sharing when you'll need at least appendonly since you're performing a write operation (upload).

Photos API Auth Docs