ERROR: The file c:\gam\oauth2service.json has an invalid format

1,681 views
Skip to first unread message

James Hatz

unread,
Oct 24, 2016, 11:31:00 AM10/24/16
to GAM for G Suite
I updated to GAM 3.7.2 and was trying out some commands this morning - want to clarify I hadn't tried this on previous versions - so can't say it worked before. 

When I try commands like:
gam all users show calendars 
or gam user username@xxx show gmail profile (using my email address) 

I get the same error:
ERROR: The file c:\gam\oauth2service.json has an invalid format

Where did I go wrong?  I got through the authorization step just fine when I upgraded and just reused my previous json file. 

James Hatz

unread,
Dec 12, 2016, 2:02:17 PM12/12/16
to GAM for G Suite
Bumping this as I never received a reply. Gam works for creating accounts but not for other functions. 

Ross Scroggs

unread,
Dec 12, 2016, 2:33:38 PM12/12/16
to google-ap...@googlegroups.com
James,

What client_secret* and oauth2service* files do you have? 

Ross

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/3d4ef803-8598-4f0d-8209-e3fda01df518%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

James Hatz

unread,
Dec 12, 2016, 2:46:50 PM12/12/16
to google-ap...@googlegroups.com
For the Client_Secrets I have a Json file. 

For oauth2service I have two - one a Json file, the other says Personal information exchange. 



James Hatz
Technology Coordinator
Rush City Schools 139
Rush City MN 55069
(320) 358-1363
twitter: @jimhatz
"Nine tenths of education is encouragement."- Anatole France, Novelist

On Mon, Dec 12, 2016 at 1:33 PM, Ross Scroggs <ross.s...@gmail.com> wrote:
James,

What client_secret* and oauth2service* files do you have? 

Ross
On Mon, Dec 12, 2016 at 11:02 AM, 'James Hatz' via GAM for G Suite <google-apps-manager@googlegroups.com> wrote:
Bumping this as I never received a reply. Gam works for creating accounts but not for other functions. 

On Monday, October 24, 2016 at 10:31:00 AM UTC-5, James Hatz wrote:
I updated to GAM 3.7.2 and was trying out some commands this morning - want to clarify I hadn't tried this on previous versions - so can't say it worked before. 

When I try commands like:
gam all users show calendars 
or gam user username@xxx show gmail profile (using my email address) 

I get the same error:
ERROR: The file c:\gam\oauth2service.json has an invalid format

Where did I go wrong?  I got through the authorization step just fine when I upgraded and just reused my previous json file. 

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsubscribe...@googlegroups.com.

To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.



--

--
You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/-s8I5amUCjY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-manager+unsub...@googlegroups.com.

To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

Ronald Jarrell

unread,
Feb 23, 2017, 11:18:48 AM2/23/17
to GAM for G Suite
I started getting this today too, while trying to set a vacation message.  I redownloaded my client_secrets.json and oauth2service.json files from the console just in case, but it still is doing it.  This is 4.03

Ross Scroggs

unread,
Feb 23, 2017, 1:17:25 PM2/23/17
to google-ap...@googlegroups.com
Ronald,

You oauth2service.json file should look like this:

{

  "type": "service_account",

  "project_id": "PROJECT-NAME",

  "private_key_id": "34048752e1f9140a450738798d329d522d9447da",

  "private_key": "-----BEGIN PRIVATE KEY-----\VERY LONG STRING of CHARACTERS\n-----END PRIVATE KEY-----\n",

  "client_email": "CLIE...@developer.gserviceaccount.com",

  "client_id": "CLIENT_ID.apps.googleusercontent.com",

  "auth_uri": "https://accounts.google.com/o/oauth2/auth",

  "token_uri": "https://accounts.google.com/o/oauth2/token",

  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",

  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/CLIENT_ID%40developer.gserviceaccount.com"

}


PROJECT_NAME is your project name
CLIENT_ID is private to you

Ross



On Thu, Feb 23, 2017 at 8:18 AM, Ronald Jarrell <jar...@vt.edu> wrote:
I started getting this today too, while trying to set a vacation message.  I redownloaded my client_secrets.json and oauth2service.json files from the console just in case, but it still is doing it.  This is 4.03

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

To post to this group, send email to google-apps-manager@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.



--

Ronald Jarrell

unread,
Feb 23, 2017, 2:09:24 PM2/23/17
to GAM for G Suite
Ross, this is what the developers console give me when I download the json:

{"installed":{"client_id":"CLIENTID","project_id":"PROJECT,"auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs"}}


On Thursday, February 23, 2017 at 1:17:25 PM UTC-5, Ross Scroggs wrote:
Ronald,

You oauth2service.json file should look like this:

{

  "type": "service_account",

  "project_id": "PROJECT-NAME",

  "private_key_id": "34048752e1f9140a450738798d329d522d9447da",

  "private_key": "-----BEGIN PRIVATE KEY-----\VERY LONG STRING of CHARACTERS\n-----END PRIVATE KEY-----\n",

  "client_email": "CLIE...@developer.gserviceaccount.com",

  "client_id": "CLIENT_ID.apps.googleusercontent.com",

  "auth_uri": "https://accounts.google.com/o/oauth2/auth",

  "token_uri": "https://accounts.google.com/o/oauth2/token",

  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",

  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/CLIENT_ID%40developer.gserviceaccount.com"

}


PROJECT_NAME is your project name
CLIENT_ID is private to you

Ross


On Thu, Feb 23, 2017 at 8:18 AM, Ronald Jarrell <jar...@vt.edu> wrote:
I started getting this today too, while trying to set a vacation message.  I redownloaded my client_secrets.json and oauth2service.json files from the console just in case, but it still is doing it.  This is 4.03

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.
To post to this group, send email to google-ap...@googlegroups.com.



--

Ronald Jarrell

unread,
Feb 23, 2017, 3:26:00 PM2/23/17
to GAM for G Suite
The bottom line, for those that read this in the future and go "Hey, that happened to me" is that once you create the service account key, and it downloads to you and says "this is your only chance", it means it.  The "download json" button in the console does not download the right json file as you see below.  Thanks to Ross, I created a new key, replacing the old one, and got my one time only download, and now life is good.

PS

unread,
Aug 21, 2017, 2:36:42 AM8/21/17
to GAM for G Suite
I have exactly same issue.
I have been using GAM  earlier and other commands like creating users have been working
But this new command gam user <em...@domain.com> show filelist is giving same error.

Please follow the instructions at this site to setup a Service Account.
ERROR: The file /path/gam/oauth2service.json has an invalid format.

oauth2service.json has an invalid format.

How come other commands are working if it is invalid format i am bit confused.If i cat it says

 cat oauth2service.json

{"installed":{"client_id":"XXXXXXXXXXXXXXX","project_id":"Project-ID","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs"}}

Ross Scroggs

unread,
Aug 21, 2017, 7:40:37 AM8/21/17
to google-ap...@googlegroups.com
PS,

In spite of what it's named, your oauth2service.json file is not a proper oauth2service.json file.

An oauth2service.json file looks like this:
{
  "type": "service_account",
  "project_id": "gam-access-xxxxxx",
  "private_key_id": "<redacted>",
  "private_key": "-----BEGIN PRIVATE KEY-----\n<redacted>\n-----END PRIVATE KEY-----\n",
  "client_id": "<redacted>",
Do you have such a file? 
If so, rename it oauth2service.json.
If not, you'll have to create a new one; there is no way to re-download the current one.
In the Devoper's Console, navigate to the API APIs & services/Credentials screen
On the Service account keys, click Manage service accounts at the far right
On the line with your GAM service account, click the three dots at the far right and then click Create key
Select Key type JSON and then click CREATE
Rename the downloaded file as oauth2service.json
Do: gam us...@domain.com check serviceaccount
Follow directions if necessary.

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.

To post to this group, send email to google-ap...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-apps-manager.
Message has been deleted

PS

unread,
Sep 1, 2017, 8:59:59 AM9/1/17
to GAM for G Suite
Thanks Ross,
For Replying, i was off didnt check the response for long. Actually we configured GAM almost 1 year back or more  now dont remember what we did.
Now i am getting new error

ERROR: Authentication Token Error - unauthorized_client: Client is unauthorized to retrieve access tokens using this method.

gam user syste...@apXXXXx.com check serviceaccount
User: XXX...@XXXX.com
 Scope: https://mail.google.com/                                     FAIL
 Scope: https://www.googleapis.com/auth/activity                     FAIL
 Scope: https://www.googleapis.com/auth/calendar                     FAIL
 Scope: https://www.googleapis.com/auth/drive                        FAIL
 Scope: https://www.googleapis.com/auth/plus.me                      FAIL
 
But it says what to do 



When i go in above linkand give Client Name it says

This client name has not been registered with Google yet. 
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-manager+unsub...@googlegroups.com.

PS

unread,
Sep 3, 2017, 11:16:22 PM9/3/17
to GAM for G Suite
AH!!!! the reason might be because i the new oauth2service.json i created has above mentioned client ID . Do i need to reinstall everything from scratch again?
Reply all
Reply to author
Forward
0 new messages