Recently upgrade my GAMADV to GAM7. Keeps getting error. "oauth2service.json, Does not exist or has invalid format,"

169 views
Skip to first unread message

Jay Vichyavichien

unread,
May 22, 2025, 5:54:32 AM5/22/25
to GAM for Google Workspace
HI Guys,

I have been using GAM for more than few years. I recently updated my GAMADV to GAM7 on my Google Cloud Shell. I have set up gam.cfg for multiple domains for my resold client domains. Never had this problem when I was using GAMADV, GAMADV-X and GAMADV-Xtd3. I follow the upgrade instruction found from https://github.com/GAM-team/GAM/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7 all the way till the end successfully. Please help.

Below was my GAM session history.

______________________________________________________________________________
jvic@cloudshell:~$ gam info domain
WARNING: Config File: /home/jvic/.gam/gam.cfg, Section: lamaicoco, Item: device_max_results, Value: 500, Expected: integer 1<=x<=200, Used: 200
Customer ID: C0___tg9
Primary Domain: lamaicoco.com
Primary Domain Verified: True
Customer Creation Time: 2024-05-07T11:46:59Z
Default Language: en
Address:
  contactName: K_____________an
  organizationName: La________________Ltd.
  addressLine1: 19______________________ok
  locality: A__________________________ni
  region: P______________i
  postalCode: 1___________0
  countryCode: T__________H
Phone: +6_______________6
Admin Secondary Email: k___________________m
User counts as of 2025-05-20:
  Total Users: 6
jvic@cloudshell:~$ gam user k____________m delete messages query 'older_than:2y'
WARNING: Config File: /home/jvic/.gam/gam.cfg, Section: lamaicoco, Item: device_max_results, Value: 500, Expected: integer 1<=x<=200, Used: 200

ERROR: Service Account OAuth2 File: /home/jvic/.gam/lamaicoco/lamai_oauth2service.json, Does not exist or has invalid format, Unable to load PEM file. See https://cryptography.io/en/latest/faq/#why-can-t-i-import-my-pem-file for more details. MalformedFraming
Please run


gam create|use project
gam user <user> update serviceaccount

to create and authorize a Service account.
jvic@cloudshell:~$ gam show svcaccts all
WARNING: Config File: /home/jvic/.gam/gam.cfg, Section: lamaicoco, Item: device_max_results, Value: 500, Expected: integer 1<=x<=200, Used: 200

Enter your Google Workspace admin or GCP project manager email address authorized to manage project(s): filter all? ad...@lamaicoco.com

Go to the following link in a browser on this computer or on another computer:

    https://accounts.google.com/o/oauth2/v2/auth?response_type=code&client_id=297408095146-fug707qsjv4ikron0hugpevbrjhkmsk7.apps.googleusercontent.com&redirect_uri=http%3A%2F%2F127.0.0.1%3A8080%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&state=G3R5KPQAZqcq3OJAnq2MjsiFxmJKve&code_challenge=JbOm8miEwRkuHMFZrvZjucdcxwFQXuK9BdZXoZjqsxI&code_challenge_method=S256&access_type=online&login_hint=admin%40lamaicoco.com

If you use a browser on another computer, you will get a browser error that the site can't be reached AFTER you
click the Allow button, paste "Unable to connect" URL from other computer (only URL data up to &scope required):

Enter verification code or paste "Unable to connect" URL from other computer (only URL data up to &scope required): http://127.0.0.1:8080/?state=G3R5KPQAZqcq3OJAnq2MjsiFxmJKve&code=4/0AUJR-x5IijPPfRCe4Vm__G4T7XN4QU5zdcs00fgujrwsSjrS3igBB0sU81mI0rkVFtb7Xg&scope=https://www.googleapis.com/auth/cloud-platform

The authentication flow has completed.
User: ad...@lamaicoco.com, Show Service Accounts for 4 Projects
Project: ga_____________5jr, Show 1 Service Account (1/4)
  email: ga________...@gam-project-dc5jr.iam.gserviceaccount.com
    displayName: GAM Project
    description: GAM Project
    oauth2ClientId: 117247676727592570072
    uniqueId: 117247676727592570072
Project: ga___________dia, Not Shown: Deleted (2/4)
Project: ga__________68, Not Shown: Deleted (3/4)
Project: ga_____________g6, Not Shown: Deleted (4/4)
jvic@cloudshell:~$ gam user k______________m delete messages query 'older_than:2y'
WARNING: Config File: /home/jvic/.gam/gam.cfg, Section: lamaicoco, Item: device_max_results, Value: 500, Expected: integer 1<=x<=200, Used: 200

ERROR: Service Account OAuth2 File: /home/jvic/.gam/lamaicoco/lamai_oauth2service.json, Does not exist or has invalid format, Unable to load PEM file. See https://cryptography.io/en/latest/faq/#why-can-t-i-import-my-pem-file for more details. MalformedFraming
Please run

gam create|use project
gam user <user> update serviceaccount

to create and authorize a Service account.
jvic@cloudshell:~$ 

___________________________________________________________________________

Ross Scroggs

unread,
May 22, 2025, 9:36:41 AM5/22/25
to google-ap...@googlegroups.com
Send me a private Meet/Zoom invitation and I'll help.

Ross
----
Ross Scroggs



--
You received this message because you are subscribed to the Google Groups "GAM for Google Workspace" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-manager/02ba1ef0-c1f2-4738-98fb-5fd93537951an%40googlegroups.com.

Ross Scroggs

unread,
May 22, 2025, 10:49:47 AM5/22/25
to google-ap...@googlegroups.com
If you were running GAMADV, you should have followed these instructions:
It simplly installs the new executable.

Did you save the existing client_secrets.json and oauth2service.json files?

As a side note, issue the following command to eliminate the warning:
WARNING: Config File: /home/jvic/.gam/gam.cfg, Section: lamaicoco, Item: device_max_results, Value: 500, Expected: integer 1<=x<=200, Used: 200
gam select default config device_max_results 200 save

Ross
----
Ross Scroggs


On May 22, 2025, at 2:54 AM, 'Jay Vichyavichien' via GAM for Google Workspace <google-ap...@googlegroups.com> wrote:

Reply all
Reply to author
Forward
0 new messages