Client is unauthorized to retrieve access tokens using this method Gmail APIClient is unauthorized to retrieve access tokens using this method Gmail API C#Error 500 backendError with Gmail API and Google APIs Node ClientGmail API - Delegating domain-wide authority to the service account to single userGmail Api return Unauthorized client or scope in requestSetting the SendAs via python gmail api returns “Custom display name disallowed”Gmail API Signature Server SideGmail API using C# to update signatureGoogleJsonResponseException: Not Found error when using Gmail API sendAs.patch method to change signature for user on domainGoogle Suite - Google API access - Client is unauthorized to retrieve access tokens using this methodGmail API Set Forwarding with Service Accountclient is unauthorized to retrieve access tokens using this method service account error

Where does "0 packages can be updated." come from?

Russian equivalents of "no love lost"

Was the Tamarian language in "Darmok" inspired by Jack Vance's "The Asutra"?

Compiling c files on ubuntu and using the executable on Windows

Why was the Sega Genesis marketed as a 16-bit console?

Find the Factorial From the Given Prime Relationship

How to build suspense or so to establish and justify xenophobia of characters in the eyes of the reader?

Soft question: Examples where lack of mathematical rigour cause security breaches?

How did they achieve the Gunslinger's shining eye effect in Westworld?

Can a user sell my software (MIT license) without modification?

Can anyone identify this tank?

Is it possible to 'live off the sea'

Should I give professor gift at the beginning of my PhD?

Taxi Services at Didcot

Was Jesus good at singing?

Movie about a boy who was born old and grew young

PhD - Well known professor or well known school?

Do simulator games use a realistic trajectory to get into orbit?

Does an ice chest packed full of frozen food need ice?

Do any instruments not produce overtones?

How to retract an idea already pitched to an employer?

How to chain Python function calls so the behaviour is as follows

Inconsistent behavior of compiler optimization of unused string

Winning Strategy for the Magician and his Apprentice



Client is unauthorized to retrieve access tokens using this method Gmail API


Client is unauthorized to retrieve access tokens using this method Gmail API C#Error 500 backendError with Gmail API and Google APIs Node ClientGmail API - Delegating domain-wide authority to the service account to single userGmail Api return Unauthorized client or scope in requestSetting the SendAs via python gmail api returns “Custom display name disallowed”Gmail API Signature Server SideGmail API using C# to update signatureGoogleJsonResponseException: Not Found error when using Gmail API sendAs.patch method to change signature for user on domainGoogle Suite - Google API access - Client is unauthorized to retrieve access tokens using this methodGmail API Set Forwarding with Service Accountclient is unauthorized to retrieve access tokens using this method service account error






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















As many other people wrote, I encounter the issue as well, I got it while trying to set new email signature via the API



The exact API call is:



sendAsConfiguration = 
'signature': 'Test email signature'

result = gmailService.users().settings().sendAs().patch(userId='xxx@domain.com',
sendAsEmail="xxx@domain.com",
body=sendAsConfiguration).execute()


The exact response is:



google.auth.exceptions.RefreshError: ('unauthorized_client: Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.', 'n "error": "unauthorized_client",n "error_description": "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."n')


My scenario is as follow:



  1. I'm working with Python from GCP Cloud Functions

  2. I manage doing requests to the G Suite directory admin, from the same code base and settings

  3. I made a service account with wild delegation. And I added the right scope both in code and in the G Suite account.

  4. When trying to work with the gmail API it doesn't work.

  5. I have created a new project, and deployed the exact same code (with settings of a new service account of course) and all worked well.

  6. I repeated all the steps for creating the service account on the original project, it still didn't work.

I need it to work from the production project, and not the test one.



I have read the following questions and answers (and many other variants of them) and nothing worked answer 1, answer 2



Regarding answer 2, I'm not sure I understood this one, so if this the real solution, it would be great getting specific steps.



I'm not adding the code itself, since it is working for sure (was tested on an different project, and worked). Please see below the settings of the service account



G Suite settings
G Suite settings
At the beginning I had both scopes under the same service account, I got the same result. In the last test I tried each service account having only one scope. Same result



Service account settings
enter image description here



Would be great getting help with that,



UPDATE 1



I have no OAuth credentials, please see the image below
Credentials



UPDATE 2



I have compared between the project who worked and the one that didn't. The only difference I noticed is, that in the working project there were no API keys. Since people wrote regarding the OAuth, I thought I might give it a chance. But since this is a production environment I don't want to remove them, especially since it was auto generated by Google, and I have no idea where they are being used. I think they aren't used anywhere, but I'm not sure.



I tried adding to the working account an API key, and it still worked, which gave me more motivation leaving the production settings untouched.



UPDATE 3



I have removed the API keys, it didn't help.



Thanks










share|improve this question
























  • From the answer 2, it was stated that the resolution would be likely to remove credentials not belonging to any service account, which leads to this github post, "I resolved my issue by removing all others types of credentials for the app in question (no oauth, just service account)".

    – MαπμQμαπkγVπ.0
    Mar 25 at 7:00











  • Thanks @MαπμQμαπkγVπ.0. I'm still puzzled, as far as I know I have no OAuth keys. Please see my attached screenshot. Did I miss anything?

    – nheimann1
    Mar 25 at 12:20

















0















As many other people wrote, I encounter the issue as well, I got it while trying to set new email signature via the API



The exact API call is:



sendAsConfiguration = 
'signature': 'Test email signature'

result = gmailService.users().settings().sendAs().patch(userId='xxx@domain.com',
sendAsEmail="xxx@domain.com",
body=sendAsConfiguration).execute()


The exact response is:



google.auth.exceptions.RefreshError: ('unauthorized_client: Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.', 'n "error": "unauthorized_client",n "error_description": "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."n')


My scenario is as follow:



  1. I'm working with Python from GCP Cloud Functions

  2. I manage doing requests to the G Suite directory admin, from the same code base and settings

  3. I made a service account with wild delegation. And I added the right scope both in code and in the G Suite account.

  4. When trying to work with the gmail API it doesn't work.

  5. I have created a new project, and deployed the exact same code (with settings of a new service account of course) and all worked well.

  6. I repeated all the steps for creating the service account on the original project, it still didn't work.

I need it to work from the production project, and not the test one.



I have read the following questions and answers (and many other variants of them) and nothing worked answer 1, answer 2



Regarding answer 2, I'm not sure I understood this one, so if this the real solution, it would be great getting specific steps.



I'm not adding the code itself, since it is working for sure (was tested on an different project, and worked). Please see below the settings of the service account



G Suite settings
G Suite settings
At the beginning I had both scopes under the same service account, I got the same result. In the last test I tried each service account having only one scope. Same result



Service account settings
enter image description here



Would be great getting help with that,



UPDATE 1



I have no OAuth credentials, please see the image below
Credentials



UPDATE 2



I have compared between the project who worked and the one that didn't. The only difference I noticed is, that in the working project there were no API keys. Since people wrote regarding the OAuth, I thought I might give it a chance. But since this is a production environment I don't want to remove them, especially since it was auto generated by Google, and I have no idea where they are being used. I think they aren't used anywhere, but I'm not sure.



I tried adding to the working account an API key, and it still worked, which gave me more motivation leaving the production settings untouched.



UPDATE 3



I have removed the API keys, it didn't help.



Thanks










share|improve this question
























  • From the answer 2, it was stated that the resolution would be likely to remove credentials not belonging to any service account, which leads to this github post, "I resolved my issue by removing all others types of credentials for the app in question (no oauth, just service account)".

    – MαπμQμαπkγVπ.0
    Mar 25 at 7:00











  • Thanks @MαπμQμαπkγVπ.0. I'm still puzzled, as far as I know I have no OAuth keys. Please see my attached screenshot. Did I miss anything?

    – nheimann1
    Mar 25 at 12:20













0












0








0








As many other people wrote, I encounter the issue as well, I got it while trying to set new email signature via the API



The exact API call is:



sendAsConfiguration = 
'signature': 'Test email signature'

result = gmailService.users().settings().sendAs().patch(userId='xxx@domain.com',
sendAsEmail="xxx@domain.com",
body=sendAsConfiguration).execute()


The exact response is:



google.auth.exceptions.RefreshError: ('unauthorized_client: Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.', 'n "error": "unauthorized_client",n "error_description": "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."n')


My scenario is as follow:



  1. I'm working with Python from GCP Cloud Functions

  2. I manage doing requests to the G Suite directory admin, from the same code base and settings

  3. I made a service account with wild delegation. And I added the right scope both in code and in the G Suite account.

  4. When trying to work with the gmail API it doesn't work.

  5. I have created a new project, and deployed the exact same code (with settings of a new service account of course) and all worked well.

  6. I repeated all the steps for creating the service account on the original project, it still didn't work.

I need it to work from the production project, and not the test one.



I have read the following questions and answers (and many other variants of them) and nothing worked answer 1, answer 2



Regarding answer 2, I'm not sure I understood this one, so if this the real solution, it would be great getting specific steps.



I'm not adding the code itself, since it is working for sure (was tested on an different project, and worked). Please see below the settings of the service account



G Suite settings
G Suite settings
At the beginning I had both scopes under the same service account, I got the same result. In the last test I tried each service account having only one scope. Same result



Service account settings
enter image description here



Would be great getting help with that,



UPDATE 1



I have no OAuth credentials, please see the image below
Credentials



UPDATE 2



I have compared between the project who worked and the one that didn't. The only difference I noticed is, that in the working project there were no API keys. Since people wrote regarding the OAuth, I thought I might give it a chance. But since this is a production environment I don't want to remove them, especially since it was auto generated by Google, and I have no idea where they are being used. I think they aren't used anywhere, but I'm not sure.



I tried adding to the working account an API key, and it still worked, which gave me more motivation leaving the production settings untouched.



UPDATE 3



I have removed the API keys, it didn't help.



Thanks










share|improve this question
















As many other people wrote, I encounter the issue as well, I got it while trying to set new email signature via the API



The exact API call is:



sendAsConfiguration = 
'signature': 'Test email signature'

result = gmailService.users().settings().sendAs().patch(userId='xxx@domain.com',
sendAsEmail="xxx@domain.com",
body=sendAsConfiguration).execute()


The exact response is:



google.auth.exceptions.RefreshError: ('unauthorized_client: Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.', 'n "error": "unauthorized_client",n "error_description": "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."n')


My scenario is as follow:



  1. I'm working with Python from GCP Cloud Functions

  2. I manage doing requests to the G Suite directory admin, from the same code base and settings

  3. I made a service account with wild delegation. And I added the right scope both in code and in the G Suite account.

  4. When trying to work with the gmail API it doesn't work.

  5. I have created a new project, and deployed the exact same code (with settings of a new service account of course) and all worked well.

  6. I repeated all the steps for creating the service account on the original project, it still didn't work.

I need it to work from the production project, and not the test one.



I have read the following questions and answers (and many other variants of them) and nothing worked answer 1, answer 2



Regarding answer 2, I'm not sure I understood this one, so if this the real solution, it would be great getting specific steps.



I'm not adding the code itself, since it is working for sure (was tested on an different project, and worked). Please see below the settings of the service account



G Suite settings
G Suite settings
At the beginning I had both scopes under the same service account, I got the same result. In the last test I tried each service account having only one scope. Same result



Service account settings
enter image description here



Would be great getting help with that,



UPDATE 1



I have no OAuth credentials, please see the image below
Credentials



UPDATE 2



I have compared between the project who worked and the one that didn't. The only difference I noticed is, that in the working project there were no API keys. Since people wrote regarding the OAuth, I thought I might give it a chance. But since this is a production environment I don't want to remove them, especially since it was auto generated by Google, and I have no idea where they are being used. I think they aren't used anywhere, but I'm not sure.



I tried adding to the working account an API key, and it still worked, which gave me more motivation leaving the production settings untouched.



UPDATE 3



I have removed the API keys, it didn't help.



Thanks







gmail-api






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 13:24







nheimann1

















asked Mar 24 at 16:29









nheimann1nheimann1

1,77111428




1,77111428












  • From the answer 2, it was stated that the resolution would be likely to remove credentials not belonging to any service account, which leads to this github post, "I resolved my issue by removing all others types of credentials for the app in question (no oauth, just service account)".

    – MαπμQμαπkγVπ.0
    Mar 25 at 7:00











  • Thanks @MαπμQμαπkγVπ.0. I'm still puzzled, as far as I know I have no OAuth keys. Please see my attached screenshot. Did I miss anything?

    – nheimann1
    Mar 25 at 12:20

















  • From the answer 2, it was stated that the resolution would be likely to remove credentials not belonging to any service account, which leads to this github post, "I resolved my issue by removing all others types of credentials for the app in question (no oauth, just service account)".

    – MαπμQμαπkγVπ.0
    Mar 25 at 7:00











  • Thanks @MαπμQμαπkγVπ.0. I'm still puzzled, as far as I know I have no OAuth keys. Please see my attached screenshot. Did I miss anything?

    – nheimann1
    Mar 25 at 12:20
















From the answer 2, it was stated that the resolution would be likely to remove credentials not belonging to any service account, which leads to this github post, "I resolved my issue by removing all others types of credentials for the app in question (no oauth, just service account)".

– MαπμQμαπkγVπ.0
Mar 25 at 7:00





From the answer 2, it was stated that the resolution would be likely to remove credentials not belonging to any service account, which leads to this github post, "I resolved my issue by removing all others types of credentials for the app in question (no oauth, just service account)".

– MαπμQμαπkγVπ.0
Mar 25 at 7:00













Thanks @MαπμQμαπkγVπ.0. I'm still puzzled, as far as I know I have no OAuth keys. Please see my attached screenshot. Did I miss anything?

– nheimann1
Mar 25 at 12:20





Thanks @MαπμQμαπkγVπ.0. I'm still puzzled, as far as I know I have no OAuth keys. Please see my attached screenshot. Did I miss anything?

– nheimann1
Mar 25 at 12:20












1 Answer
1






active

oldest

votes


















0














I found this to be a Roles issue for the service account.



  1. In your Developers Console -> Project -> IAM ensure that your service account is listed there.

    • if it isn't, click Add and start typing the name to add it


  2. For Role, select Access Approval -> Access Approval Approver

This allowed me to query any domain user's calendar event list.






share|improve this answer























  • Thank you, but it doesn't solve my issue. As the question says. It does work for me with the same project for some of the API but not for all. I still didn't solve this issue

    – nheimann1
    Apr 23 at 14:02











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325978%2fclient-is-unauthorized-to-retrieve-access-tokens-using-this-method-gmail-api%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I found this to be a Roles issue for the service account.



  1. In your Developers Console -> Project -> IAM ensure that your service account is listed there.

    • if it isn't, click Add and start typing the name to add it


  2. For Role, select Access Approval -> Access Approval Approver

This allowed me to query any domain user's calendar event list.






share|improve this answer























  • Thank you, but it doesn't solve my issue. As the question says. It does work for me with the same project for some of the API but not for all. I still didn't solve this issue

    – nheimann1
    Apr 23 at 14:02















0














I found this to be a Roles issue for the service account.



  1. In your Developers Console -> Project -> IAM ensure that your service account is listed there.

    • if it isn't, click Add and start typing the name to add it


  2. For Role, select Access Approval -> Access Approval Approver

This allowed me to query any domain user's calendar event list.






share|improve this answer























  • Thank you, but it doesn't solve my issue. As the question says. It does work for me with the same project for some of the API but not for all. I still didn't solve this issue

    – nheimann1
    Apr 23 at 14:02













0












0








0







I found this to be a Roles issue for the service account.



  1. In your Developers Console -> Project -> IAM ensure that your service account is listed there.

    • if it isn't, click Add and start typing the name to add it


  2. For Role, select Access Approval -> Access Approval Approver

This allowed me to query any domain user's calendar event list.






share|improve this answer













I found this to be a Roles issue for the service account.



  1. In your Developers Console -> Project -> IAM ensure that your service account is listed there.

    • if it isn't, click Add and start typing the name to add it


  2. For Role, select Access Approval -> Access Approval Approver

This allowed me to query any domain user's calendar event list.







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 22 at 21:09









sean.hudsonsean.hudson

108212




108212












  • Thank you, but it doesn't solve my issue. As the question says. It does work for me with the same project for some of the API but not for all. I still didn't solve this issue

    – nheimann1
    Apr 23 at 14:02

















  • Thank you, but it doesn't solve my issue. As the question says. It does work for me with the same project for some of the API but not for all. I still didn't solve this issue

    – nheimann1
    Apr 23 at 14:02
















Thank you, but it doesn't solve my issue. As the question says. It does work for me with the same project for some of the API but not for all. I still didn't solve this issue

– nheimann1
Apr 23 at 14:02





Thank you, but it doesn't solve my issue. As the question says. It does work for me with the same project for some of the API but not for all. I still didn't solve this issue

– nheimann1
Apr 23 at 14:02



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55325978%2fclient-is-unauthorized-to-retrieve-access-tokens-using-this-method-gmail-api%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript