Best way to create new oauth2.txt for multiple domains in same GAM directory?

898 views
Skip to first unread message

Nate Ferrell

unread,
Jan 14, 2016, 9:56:16 PM1/14/16
to Google Apps Manager
Hey guys,

What would be the best way to create a new OAUTH.txt file to be able to use with the same client secrets? 

Thinking along the lines of creating "oauth2.txt-domain1.com", "oauth2.txt-domain2.com", etc, to be able to switch between OAUTH's using the "set OAUTHFILE=oauth2.txt-domain1.com" command, for example.

Graham Ingleby

unread,
Jan 15, 2016, 6:51:57 AM1/15/16
to GAM group
That would work, I use "set oauthfile=domain.com.txt" just so it is a text file and Windows doesnt think it is a COMMAND file, but apart from that it works great.
run the set command, then create the oauth file and you are good to go

 

 Graham Ingleby | Cloud Computing Consultant | +44 1344 203395 | ging...@ancoris.com

Google+              

--
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 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/a44e8ed2-cda2-4eb1-9ce9-f09b0d84e9b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



This message is for the named person's use only. If you receive this message in error, please delete it and notify the sender. Ancoris reserves the right to monitor all e-mail communications through its networks. Ancoris Limited, Registered in England Number: 04830784, Registered address: 5a Frascati Way, Maidenhead, Berkshire SL6 4UY. Trading Address: Lily Hill House, Lily Hill Road, Bracknell, Berkshire RG12 2SJ




onixterry

unread,
Jan 15, 2016, 1:03:13 PM1/15/16
to Google Apps Manager
For multiple domains I just download GAM multiple times and create a separate directory for each.  If I want to perform tasks for a specific domain, I just switch to that directory.  

Nate Ferrell

unread,
Jan 15, 2016, 2:08:33 PM1/15/16
to Google Apps Manager
This is currently what I'm doing, but I'm working on a project to offer multiple installation and multiple OAUTH per installation directory path capabilities with GAM, so I need to also get the multiple OAUTH files working within the same directory

Nate Ferrell

unread,
Jan 15, 2016, 2:10:47 PM1/15/16
to Google Apps Manager
Awesome!

So, just to sanity check: You set the environmental oauthfile variable to a new text name, then simply run through the API selection process and reauth to a new domain instead, which writes the info to the txt file designated when setting the oauthfile variable? Then you simple set the oauthfile variable to the filename that you want to use from that point?

On Friday, January 15, 2016 at 3:51:57 AM UTC-8, Graham Ingleby wrote:
That would work, I use "set oauthfile=domain.com.txt" just so it is a text file and Windows doesnt think it is a COMMAND file, but apart from that it works great.
run the set command, then create the oauth file and you are good to go

 

 Graham Ingleby | Cloud Computing Consultant | +44 1344 203395 | ging...@ancoris.com

Google+              

On 15 January 2016 at 02:56, Nate Ferrell <nathanie...@pnmac.com> wrote:
Hey guys,

What would be the best way to create a new OAUTH.txt file to be able to use with the same client secrets? 

Thinking along the lines of creating "oauth2.txt-domain1.com", "oauth2.txt-domain2.com", etc, to be able to switch between OAUTH's using the "set OAUTHFILE=oauth2.txt-domain1.com" command, for example.

--
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-manager+unsub...@googlegroups.com.

Nate Ferrell

unread,
Jan 16, 2016, 8:00:49 PM1/16/16
to Google Apps Manager
Got it working!

For those that are curious on how to create a new OAuthFile with the same client_secrets.json and gam installation:

1. Set the OAUTHFILE variable to the name of the new text file you'd like to create
a. If using CMD on Windows, do this with:
set OAUTHFILE="filename.txt"

b. If using PowerShell on Windows, do this with:
$env:OAUTHFILE="filename.txt"
2. Run the gam info domain command, you'll receive the API selection prompt
3. Choose your API's
4. During the browser popup, authenticate to Google with the user/domain that you'd like to bind to the new OAUTHFILE
5. Confirm that this was successful by viewing the results of gam info domain, or by running a following gam info user to view the current auth user's info (useful if switching between accounts on the same domain)


Once done, you'll be set to use the new OAUTHFILE for the remainder of the session. Keep in mind that GAM will revert to the original oauth2.txt file if you start a new session. To swap between oauthfile's in the same session, simply set the OAUTHFILE variable above to the file you'd like to run commands with using the commands above =]


If you are in Powershell and would like it to default to a specific OAUTHFILE, you can do one of the following:

a) Set the variable in your Powershell profile by adding this, forcing it to set that variable on every load:
$env:OAUTHFILE="filename.txt"

b) Create a new environment variable using .NET for Powershell to use and set it's default value to your desired filename:
[Environment]::SetEnvironmentVariable("OAUTHFILE", "filename.txt", "User")
-  OAUTHFILE is the name of variable (do not change this as this is what GAM references by variable name)
- "filename.txt" is the filename of your desired default oauthfile
- "User" is the scope of the environmental variable (this can be set to either "User", "Machine", or "Process", but you're best leaving as User I believe) 

Graham Ingleby

unread,
Jan 18, 2016, 4:41:23 AM1/18/16
to GAM group
That must be a real pain when you upgrade the version of GAM. Give "set oauthfile=domain.com.txt" a go, it really is easy, then come upgrade time you upgrade once for all domains


 

 Graham Ingleby | Cloud Computing Consultant | +44 1344 203395 | ging...@ancoris.com

Google+              

--
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 https://groups.google.com/group/google-apps-manager.

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

Graham Ingleby

unread,
Jan 18, 2016, 4:42:44 AM1/18/16
to GAM group
Yes, thats about it - you need to allow your one Service Account access in the Security settings for each domain as well of course


 

 Graham Ingleby | Cloud Computing Consultant | +44 1344 203395 | ging...@ancoris.com

Google+              

On 15 January 2016 at 19:10, Nate Ferrell <nathanie...@pnmac.com> wrote:
Awesome!

So, just to sanity check: You set the environmental oauthfile variable to a new text name, then simply run through the API selection process and reauth to a new domain instead, which writes the info to the txt file designated when setting the oauthfile variable? Then you simple set the oauthfile variable to the filename that you want to use from that point?

On Friday, January 15, 2016 at 3:51:57 AM UTC-8, Graham Ingleby wrote:
That would work, I use "set oauthfile=domain.com.txt" just so it is a text file and Windows doesnt think it is a COMMAND file, but apart from that it works great.
run the set command, then create the oauth file and you are good to go

 

 Graham Ingleby | Cloud Computing Consultant | +44 1344 203395 | ging...@ancoris.com

Google+              

On 15 January 2016 at 02:56, Nate Ferrell <nathanie...@pnmac.com> wrote:
Hey guys,

What would be the best way to create a new OAUTH.txt file to be able to use with the same client secrets? 

Thinking along the lines of creating "oauth2.txt-domain1.com", "oauth2.txt-domain2.com", etc, to be able to switch between OAUTH's using the "set OAUTHFILE=oauth2.txt-domain1.com" command, for example.

--
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.


This message is for the named person's use only. If you receive this message in error, please delete it and notify the sender. Ancoris reserves the right to monitor all e-mail communications through its networks. Ancoris Limited, Registered in England Number: 04830784, Registered address: 5a Frascati Way, Maidenhead, Berkshire SL6 4UY. Trading Address: Lily Hill House, Lily Hill Road, Bracknell, Berkshire RG12 2SJ




--
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 https://groups.google.com/group/google-apps-manager.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages