I'm trying to run the Quickstart in Python for the Group Migration API.
The goal is to insert a message to a Google group that I created for testing.
I've created a Google for Work account, and made a Google group that is owned by admin.
I created the credentials in console as "Client ID for Other" and set them up on my client.
When I run the script, I get:
googleapiclient.errors.HttpError:
<HttpError 400 when requesting
https://www.googleapis.com/upload/groups/v1/groups/test-migration-business%40googlegroups.com/archive?uploadType=media&alt=json
returned "com.google.gaia.client.InvalidUserIDException:
Request for GaiaClientConst::INVALID_USERID">
The authorization flow appeared to work fine. I get the confirmation in the browser tab. It creates the credentials file in my local directory.
I am authorizing as the admin user of the Google for Work account. I've enabled API access in the admin.google.com console. I've also been through the Prerequisites steps, and I think it's all set up OK.
Any idea what causes this?
Edit: I got some more information through another channel. The problem was with the group to which I was trying to post via the API.
It's not just about creating the group under a Google Groups for Business account. You have to go through a lot of setup in the admin.google.com panel. Eventually when you set it up right, you can create a group whose e-mail address is of the type: [email protected].
As long as it's creating your groups with the @googlegroups.com suffix in the e-mail address, the API call won't work.
I will write an alternative answer in a couple of days once I've explored doing this with SMTP e-mail adds instead.
The problem was with the group to which I was trying to post via the API.
It's not just about creating the group under a Google Groups for Business account. You have to go through a lot of setup in the admin.google.com panel. Eventually when you set it up right, you can create a group whose e-mail address is of the type: [email protected].
As long as it's creating your groups with the @googlegroups.com suffix in the e-mail address, the API call won't work.
I went down the path of using SMTP to post to a public group as per these links: https://github.com/jmuhlich/mailman-archive-migration https://gist.github.com/tdonohue/cd2a643c5fca5f140cfd
I encountered some difficulties with the SMTP approach and eventually abandoned it.
a) You need to load messages in chronological order, as they post with the current date/time when you add them. They can get out of order if the e-mail gets held in moderation queue as spam and approved later.
b) There's now a very low limit on Google's SMTP relay, unless you have a big bucks Google Apps account with a large number of subscribed users. The SMTP relay service becomes important so that your archived messages don't get marked as spam on the way in to the group.
I have gone back to the API solution and have almost finished it. It took a bit of time to get encoding of charsets to work right in all cases. But otherwise it works well.