googleapis / googleapis/google-api-dotnet-client
Per-request AddCredential not working with BatchRequest
- 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
Assessment
This issue has not been assessed yet.