gam create resource not working

132 views
Skip to first unread message

Romain Schmid - admin

unread,
Nov 10, 2015, 1:56:57 PM11/10/15
to Google Apps Manager
I've posted about that a few hours ago, but deleted it because I wanted to investigate a little more. 

I've gam 3.6.1, client_secrets and oauth2 ok, I can use the gam user test show calendars, fine. 

If I try the 
gam create resource ordi-lm010540-poste "Ordi lm010540 Poste" description "Ordinateur portable avec alimentation et sacoche" type ordi
command, Terminal (I'm on Mac) just hangs, nothing happens. This command used to work perfectly, and I've typed it like this. 

I've been able to go in the admin.google console, and create a resource manually. Can someone point what I've done wrong ?

Thanks

Romain

Ross Scroggs

unread,
Nov 10, 2015, 3:02:26 PM11/10/15
to google-ap...@googlegroups.com
Romain,

At console.developers.google.com, note the OAuth 2.0 client ID and the Service account Email address.

Verify that you have all of the APIs enabled:

Admin SDK

Apps Activity API

Calendar API

Drive API

Enterprise License Manager API

Gmail API

Google Classroom API

Groups Settings API


Logged on to admin.google.com, navigate to Admin console/Security/Show more/Advanced settings/Manage API client access.

The OAuth 2.0 client ID should be authorized for these scopes:

https://mail.google.com/,

https://www.googleapis.com/auth/admin.datatransfer,

https://www.googleapis.com/auth/admin.directory.customer,

https://www.googleapis.com/auth/admin.directory.domain,

https://www.googleapis.com/auth/calendar,

https://www.googleapis.com/auth/classroom.courses,

https://www.googleapis.com/auth/classroom.profile.emails,

https://www.googleapis.com/auth/classroom.profile.photos,

https://www.googleapis.com/auth/classroom.rosters,

https://www.googleapis.com/auth/cloudprint,

https://www.googleapis.com/auth/drive,

https://www.googleapis.com/auth/plus.login,

https://www.googleapis.com/auth/plus.me,

https://www.googleapis.com/auth/siteverification


The Service account Email address should be authorized for these scopes:

https://mail.google.com/,

https://www.googleapis.com/auth/activity,

https://www.googleapis.com/auth/calendar,

https://www.googleapis.com/auth/drive


Verify that these are set correctly.


Does this help?


Ross



--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" 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 http://groups.google.com/group/google-apps-manager.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/e01ef1d0-e26d-40d5-ab8b-80bb46c1023f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Romain Schmid - admin

unread,
Nov 10, 2015, 4:33:12 PM11/10/15
to Google Apps Manager
Hi Ross, 

Thanks for your answer. That is definitely the thing I had missed. I had set GAM up a last year, and after a new installation, I've forgotten this point. I've added the "Apps Activity API", a new one this one ?

But still, I'm a bit confused. You talk about 2 things : first the OAuth2 ID (number 1, on screenshot) and secondly the Service account email (number 2). 

I can add the OAuth2 ID in the API access part of the admin console, but not the Service account mail, it says that "this client's name has not been registered yet at Google's" (translation from French, might sound a little strange).


Here is another screenshot of what I have at the moment. Number 3 is the Client ID named "1" on the previous screenshot. I've tried to add the number 2 address, but I get the mentioned message.



I hope my explanation is clear. I've set it up perfectly last time, worked like a charm. I must say that the documentation could be a little more explicit, I am not a developer, just a teacher ! But Google keeps on changing its tools aspect, so maintaining a good and clear doc for a bore like me must be time consuming ;-)



Ross Scroggs

unread,
Nov 10, 2015, 4:55:40 PM11/10/15
to google-ap...@googlegroups.com
Romain,

Use xxxxxxxx.apps.googleusercontent.com in Number 4

Ross

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" 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 http://groups.google.com/group/google-apps-manager.

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



--

Ross Scroggs

unread,
Nov 10, 2015, 5:05:45 PM11/10/15
to google-ap...@googlegroups.com
Romain,

1 and 2 should both be of the form: nnnnmmmmoooo-xxxxxxxxxxxxx.apps.googleusercontent.com

nnnnmmmmoooo should be the same for both of them.

Ross
--

Romain Schmid - admin

unread,
Nov 10, 2015, 5:46:10 PM11/10/15
to Google Apps Manager

Ross, 

Thanks for your patience. But you'll need some more...

Screenshots might be clearer than my explanations. I've tried and summarize the things I've got so far. There are 2 pictures joined, the black arrow shows the screen I get if i click on the email address below the start of the arrow.

Under "1", the OAuth ID 2.0 created, and where I've downloaded a file name client_secretXXXXXXXXXX.json, which I renamed client_secrets.json. Right ?
Under "2", the screen I get if I click on the "Service account" email link, where I've downloaded the json version, not the p12, and renamed oauth2service.json. Still right ?
Then, I've copied "3" and allowed the big list of scopes.
Copied "4" and allow the small list of scopes. 


Both "things" I've copied begin with the same sequence, and end with this apps.googleusercontent.com suffix. 


Romain


 

Ross Scroggs

unread,
Nov 10, 2015, 5:50:30 PM11/10/15
to google-ap...@googlegroups.com
Romain,

All of those steps appear correct.

Have you done the following two steps? They will update your oauth2.txt file. You should be logged on at admin.google.com when you run these commands.

gam oauth revoke
gam oath create

Ross

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" 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 http://groups.google.com/group/google-apps-manager.

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



--

Romain Schmid - admin

unread,
Nov 10, 2015, 6:10:26 PM11/10/15
to Google Apps Manager
Ross, 

Thanks again. 

I've followed the two steps, and still no success with the create resource command. 

I have to go to bed (midnight here) and if I am more tired than my students tomorrow morning, it won't be easy ! ;-)

I'll read your response tomorrow, if you don't mind...

Good night, 

Cheers

Ross Scroggs

unread,
Nov 10, 2015, 6:46:45 PM11/10/15
to google-ap...@googlegroups.com
Romain,

gam create resource ordi-lm010540-poste "Ordi lm010540 Poste" description "Ordinateur portable avec alimentation et sacoche" type ordi

should be

gam create resource ordi-lm010540-poste "Ordi lm010540 Poste" description "Ordinateur portable avec alimentation et sacoche" restype ordi

On create you say restyle, on update you say type.

Ross

--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" 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 http://groups.google.com/group/google-apps-manager.

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



--

Romain Schmid - admin

unread,
Nov 11, 2015, 8:40:05 AM11/11/15
to Google Apps Manager
Ross, 

I am very confused now : your suggestion doesn't work, and I doubt it will ever, since the "official" syntax found in the wiki doesn't mention this particular detail of "restype". Btw, did you mistype when you write "restyle" ?
Speaking of syntax, gam should display a line saying there is something wrong with it, it shouldn't just hang and do nothing, am I wrong ?

I think I am going to take things from scratch again, triple-check every single step, and see if something better happens. I hope I have the right steps to generate all json files etc. As I said before, it is a little difficult to know if everything is ok since the developers console is not the same anymore. Especially when I have to choose if the file I want to create is for an installed application : nowhere during the process (and I've checked all possibilities and menues) this step appears.

Thanks again for your help, I am going to take some time to try and figure this out. 

Romain

Ross Scroggs

unread,
Nov 11, 2015, 9:23:59 AM11/11/15
to google-ap...@googlegroups.com
Romain,

Yes, restyle was an autocorrect of restype, I apologize.

In GAM 3.51, it was: gam create resource ... type xxx
In GAM 3.6 and later it is: gam create resource ... restype xxx

The Wiki is correct but a typo slipped into the code.
It hangs because that particular function does not flag an unknown argument (type in this case) and loops infinitely.

You're fine on the console stuff, just try it with restype.
gam update resource still uses type.


--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" 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 http://groups.google.com/group/google-apps-manager.

Romain Schmid - admin

unread,
Nov 11, 2015, 9:34:08 AM11/11/15
to Google Apps Manager
Ross, 

Still no success. I am currently creating a series of screenshots, I will give it to you in a few minutes, just to show you every step I go through. 

Here is my last try : 

Ross Scroggs

unread,
Nov 11, 2015, 9:40:58 AM11/11/15
to google-ap...@googlegroups.com
Romain,

I found the problem.

Here is the function, it starts at line 5098, the problem is line 5108, it can never be true.
def doCreateResource():
  resId = sys.argv[3]
  common_name = sys.argv[4]
  description = None
  resType = None
  i = 5
  while i < len(sys.argv):
    if sys.argv[i].lower() == u'description':
      description = sys.argv[i+1]
      i += 2
    elif sys.argv[i].lower() == u'resType':
      resType = sys.argv[i+1]
      i += 2
  rescal = getResCalObject()
  callGData(service=rescal, function=u'CreateResourceCalendar', id=resId, common_name=common_name, description=description, type=resType)

Line 5108 should read:
    elif sys.argv[i].lower() == u'type':

Backup your copy, make the change and you're good to go.

I've submitted a pull request to Jay to correct the problem.

Ross


--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" 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 http://groups.google.com/group/google-apps-manager.

Romain Schmid - admin

unread,
Nov 11, 2015, 9:44:19 AM11/11/15
to Google Apps Manager
Here is the link to the document I just made. Some steps are unuseful, but... devil is in the details here !


And again, thanks for your help and patience !

Romain Schmid - admin

unread,
Nov 11, 2015, 9:48:41 AM11/11/15
to Google Apps Manager
Wow, cool indeed !

Well, I am not sure how to do this, since I don't code... I will give it a try anyway. I'll keep you updated. Thanks ! If I can help the documentation, it would be a pleasure, I could make the doc I've given to you a little better, in order to help other people setting up these json files ?

Romain Schmid - admin

unread,
Nov 11, 2015, 9:52:29 AM11/11/15
to Google Apps Manager
Champagne !

You found it. I must say I am glad it wasn't making the mistake !

I'll buy you a beer if you come to Switzerland !

Romain

Ross Scroggs

unread,
Nov 11, 2015, 10:22:11 AM11/11/15
to google-ap...@googlegroups.com
Romain,

Thanks, but I don't deserve it. I went back through the GAM changes log and I made the typo that chnaged 'type' to 'resType'.
My apologies to you and Jay.


--
You received this message because you are subscribed to the Google Groups "Google Apps Manager" 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 http://groups.google.com/group/google-apps-manager.
Reply all
Reply to author
Forward
0 new messages