Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple API keys #152

Closed
radar opened this issue Dec 26, 2009 · 5 comments
Closed

Multiple API keys #152

radar opened this issue Dec 26, 2009 · 5 comments
Labels

Comments

@radar
Copy link

radar commented Dec 26, 2009

As a developer for Mocra and an open source guy, sometimes I publish gems under the dev@mocra account and other times at my own personal account. In order to do this however I need to edit the ~/.gem/credentials file every time I need to switch. Whilst it would be easy for me to make a script to just mv the file elsewhere and copy over the new one, I think there would also be other people in this situation.

@qrush
Copy link
Member

qrush commented Dec 26, 2009

Agreed, this is why ~/.gem/credentials is a YAML file...so this could be implemented something like...

gem push whatever.gem -k mocra

and in the credentials file:

---
:rubygems_api_key: 1337
:mocra_api_key: 42

@sr
Copy link

sr commented Dec 26, 2009

Makes me think of something related... we want to run a gemcutter instance to host our internal gems. Currently we have a company-specific gem which is exactly like the gemcutter one except it only provides the push command and point to our server. What if gemcutter supported something like:

gem push foo.gem -h foo

with h standing for host and defaulting to gemcutter. And the YAML file:

---
gemcutter:
  api_key: foo
  url: http://gemcutter.org
foo:
  api_key: bar
  url: http://gems.example.org

I'd be happy to submit a patch if you are ok with this.

@qrush
Copy link
Member

qrush commented Dec 26, 2009

I like that approach better, sr...however we'll have to continue to support :rubygems_api_key since the gemcutter gem looks at that too. So perhaps the default could be

---
rubygems:
  api_key: foo
  address: http://rubygems.org

Thankfully since it's parsed as a YAML file we should be able to drop this in.

@qrush
Copy link
Member

qrush commented Mar 18, 2011

This is done! rubygems/rubygems#17

@qrush qrush closed this as completed Mar 18, 2011
@johnl
Copy link

johnl commented Jul 25, 2018

as this is the top search result for this problem and since I spent 20 minutes trying to figure out the right config format, I thought I'd clarify it here for others. Just specify each key as a symbol in ~/.gem/credentials and specify which you want with -k

---
:work: b026324c6904b2a9cb4b88d6d61c81d1
:personal: b026324c6904b2a9cb4b88d6d61c81d1
gem push -k work mygem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants