gsutil

2,355 views
Skip to first unread message

Wilson MacGyver

unread,
Apr 22, 2012, 10:02:57 PM4/22/12
to gs-dis...@googlegroups.com
Can gsutil be setup to use two different oauth 2.0 tokens?

ie, I'd like to use gstuils to access multiple google storage accounts.

Thanks

--
Omnem crede diem tibi diluxisse supremum.

Google Storage Team

unread,
Apr 22, 2012, 10:29:31 PM4/22/12
to gs-dis...@googlegroups.com
Hi Wilson,

One way to accomplish this would be to setup two boto configuration files, one for each set of OAuth credentials. Then you could specify the desired configuration by setting (and exporting) the BOTO_CONFIG environment variable to the desired config file's path name. You could also create simple shell scripts to wrap this functionality, like this one (assume your config files are named .boto1 and .boto2):

$ cat $HOME/bin/gs1
#!/bin/sh 
export BOTO_CONFIG=$HOME/.boto1
gsutil $*

and similarly for gs2/.boto2. Or you could write a single script that takes an argument specifying the desired environment. See 'gsutil help config'  for more info on configuration files, options and settings.

Marc
Google Cloud Storage Team

--
You received this message because you are subscribed to the Google Groups "Google Cloud Storage" group.
To post to this group, send email to gs-dis...@googlegroups.com.
To unsubscribe from this group, send email to gs-discussio...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gs-discussion?hl=en.


Wilson MacGyver

unread,
Apr 22, 2012, 11:27:16 PM4/22/12
to gs-dis...@googlegroups.com
bummer, I was afraid of that :)

so far my solution is setup multiple user accounts on the linux server which
has the master files.

Google Storage Team

unread,
Apr 23, 2012, 11:18:39 AM4/23/12
to gs-dis...@googlegroups.com
One more suggestion for you, Wilson -- here's how a colleague solves this problem:

=========
The way I do this is I have a set of shell functions that export different values for BOTO_CONFIG, e.g.,:

prodenv () 
    gsenv="prod service using prod OAUTH2 credentials";
    export BOTO_CONFIG=$HOME/.boto_prod_oauth
}

That way I just execute one of these funcs and then can just run gsutil, without setting up aliases. (I think "gs1" is less mnemonically meaningful.) Also, I have a gsenv function for echoing the content of gsenv, so you can see what env you have by running that function.
=========

This is also switching between multiple static boto config files, however, I find this approach cleaner and a bit more manageable than my earlier suggestion.

Marc

Google Storage Team

unread,
Apr 23, 2012, 12:09:08 PM4/23/12
to gs-dis...@googlegroups.com
Sorry for the shotgun approach but here's yet another idea: in each of your projects grant edit access to one (or more) of your accounts. Then you'd only need to worry about specifying/switching projects at bucket creation time (which can be done via a gsutil command line option). Thereafter, you should be able to create and access objects in all your projects with one set of OAuth credentials.

Marc

Wilson MacGyver

unread,
Apr 23, 2012, 12:24:38 PM4/23/12
to gs-dis...@googlegroups.com
Sadly that doesn't work. Several of them are tied to google apps account.

What I noticed is, if you created the API console google storage using x...@a.com, you can't add anyone outside of that domain to the project. So you can't add x...@b.com or x...@gmail.com
Reply all
Reply to author
Forward
0 new messages