Closed waterlink closed 10 years ago
I also encountered this issue when using hub on a second laptop. As @waterlink points out, it seems to be the duplicate OAuth token description (note
in the API call) that causes the problem. Rather than make a change in code, I went to the Github website & changed the token description used by my other computer (under Account Settings > Applications).
I assume that registering hub with a unique token (e.g. hug-xx123
) on first authentication would solve the problem.
:+1: This has been biting me, too.
:+1: Thanks for explaining it. I just renamed them to "hub-
Ideally, it would be creating something like that. If there was a collision, then it should present the link to the page where you can rename them or offer to rename them itself.
Ciao!
Is it possible to generate something like "hub-{long-random-unique-hash-here-from-your-laptop-metadata}" ?
@docwhat thanks for the tip. Renaming my existing hub allowed me to register a new one. Now I'll just name them hub-#{hostname}
manually at https://github.com/settings/applications.
How about something like that?
res = post auth_url,
:scopes => %w[repo], :note => "hub-#{get_unique_host_id}", :note_url => oauth_app_url do |req|
req['X-GitHub-OTP'] = two_factor_code if two_factor_code
end
where get_unique_host_id
may be something like that (for Linux):
def get_unique_host_id
if OS::linux?
`hostid`
elsif OS::windows?
# do similar thing for windows
elsif OS::macosx?
# do similiar thing for macos
end
end
Or we can just generate this unique id and store it somewhere in the system, for example together with oauth tokens.
I've already fixed this, pending push and release. No unique identifiers necessary.
@mislav thanks!
This fix is released. Now if there's any token named "hub", we reuse that as well. This will avoid trying to create another token with the same name "hub" and hitting the validation error.
You can delete other tokens for hub that you've renamed and just keep the one that has "hub" for description.
I ran into this issue today. I installed hub:
I had to rename all my existing hub tokens to hub-{noise}
.
$ hub --version
git version 1.9.1
hub version 1.12.0-10-g67728bc
@Raynos I'm sorry to hear that. Version 1.12.0 definitely includes this fix, and there's a test for this behavior. Is it possible that you had an older version of hub at the time you tried to re-auth, or that you might have two versions of hub on your system? where -a hub
Anyways, now that you worked aroun this, you can delete the old hub-{noise}
tokens now; they're of no use to anything anymore.
I had hub running ok on another laptop three months ago.
Now I have installed hub again on new laptop from gem (Ubuntu 13.10, rvm, ruby 2.0.0-p353).
No command related to github is working. Just unable to authenticate. For example
outputs following stack trace:
A bit of inspecting ruby files and adding debug output before exception raised resulted to pinpointing problem. Response body from github oauth is following:
So,
"code": "already_exists"
. I had a guess to change 'note' sent to github oauth to something another inGitHubAPI::HttpMethods::OAuth#obtain_oauth_token
method:And it worked out for me. And obtained new authentication.