Skip to content

Per-request AddCredential not working with BatchRequest #2065

@mikequ-taggysoft

Description

@mikequ-taggysoft

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<SendRequest>
        (_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.

Metadata

Metadata

Assignees

Labels

priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions