googleapis / googleapis/google-api-dotnet-client

Per-request AddCredential not working with BatchRequest

Open
#2,065 10 comments 0 reactions 0 assignees View on GitHub
priority: p3 type: feature request
Dominant language
C#
Stars
1.5k
Forks
558
Avg merge
16h 34m
Merged PRs (30d)
17

Description

With the per-request credential example provided by @amanda-tarafa in #2064, I was able to get it working for services like Calendar and Oauth2. But I'm having trouble with `GmailService`.

I use `GmailService` via `BatchRequest`, like this

```
var cred = GoogleCredential.FromAccessToken(myToken);

var batchRequest = new BatchRequest(_gmailService);

foreach (var gmailMessage in gmailMessages)
{
batchRequest.Queue
(_gmailService.Users.Messages.Send(gmailMessage, "me").AddCredential(cred), myCallback));
}

await batchRequest.ExecuteAsync();
```
I'm getting error:

> Error 401, Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.