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

Token with bitbucket? #4

Open
allaire opened this issue Dec 28, 2013 · 13 comments
Open

Token with bitbucket? #4

allaire opened this issue Dec 28, 2013 · 13 comments

Comments

@allaire
Copy link

allaire commented Dec 28, 2013

Which token are we supposed to use with Bitbucket? Currently I'm using username/password, and using the API key as the password.

@c10l
Copy link
Owner

c10l commented Dec 28, 2013

I'm not sure what's the API key you're using for password. My understanding is that if you use HTTP Basic authentication (as when you supply the LWRP with a user/pass combination) you're using an actual Bitbucket user and its password for credentials.

The token authentication scheme is for OAuth tokens.

@allaire
Copy link
Author

allaire commented Dec 28, 2013

See here: https://confluence.atlassian.com/display/BITBUCKET/Use+the+Bitbucket+REST+APIs#UsetheBitbucketRESTAPIs-Authentication

You can use the Bitbucket API key for authentification (password).

The page oauth page you linked to creates two keys

@c10l
Copy link
Owner

c10l commented Jan 24, 2014

Hey, sorry for not having looked into this for so long, but I was busy moving to another country. :)

I couldn't find any mention to an API key on the docs you linked. That's for a user's username and password as I mentioned before (or I might be drunk).

For the OAuth scheme, you have to create an Application Key first, then create an Access Token. The latter is the one you'll use to authenticate against the API.

@bgaillard
Copy link

Hi, I follow the guide provided here to create an Access Token.

https://confluence.atlassian.com/display/BITBUCKET/OAuth+on+Bitbucket

At the end of the guide (Step 4. Request an Access Token) the last request returns something like this :

oauth_token_secret=XXXX&oauth_token=YYYY

What do I have to use in the :token parameter ? Is it XXXX or YYYY ?

I tried both but I always get an HTTP 403 error (Access Forbidden).

deploy_key "bitbucket_key" do
  provider Chef::Provider::DeployKeyBitbucket
  path '/home/vagrant/.ssh'
  credentials({
    :token => 'XXXX'
  })
  repo 'my_company/my_project'
  owner 'vagrant'
  group 'vagrant'
  mode 00640
  action :add
end

Thanks,

Baptiste

@c10l
Copy link
Owner

c10l commented Apr 2, 2014

I have to be honest with you and say that I haven't used this auth mechanism in BitBucket.

That said, have you tried sending the whole string, as in :token => 'oauth_token_secret=XXXX&oauth_token=YYYY'? That seems to be what you need. Let me know if it works for you.

@bgaillard
Copy link

Hi @cassianoleal, thanks for you quick response.

I tried with :token => 'oauth_token_secret=XXXX&oauth_token=YYYY' but encounter the same 403 error code.

@mariomarin
Copy link

@bgaillard Did you find a workaround?

@bgaillard
Copy link

Hi @mariomarin, sadly I did not found any solution for this, let me know if you find a workaround.

@c10l
Copy link
Owner

c10l commented Jul 10, 2014

I've been doing some reading, and this should actually have been a full-blown OAuth implementation. I'll have to study it a bit further in order to get this to work, and I'm not sure I'll have the time any time soon.

If any of you want to take a stab at it, please do so. Pull requests are always welcome! 😄

@paralin
Copy link

paralin commented Jul 17, 2014

Wow, the last message on this is really recent.

I'd also like to set this up properly. It seems you have to get the token like

https://bitbucket.org/api/1.0/oauth/request_token?oauth_version=1.0&oauth_nonce=7f2325b3c36bd49afa0a33044d7c6930&oauth_timestamp=1366243208&oauth_consumer_key=HUpRcDUduZrepL6sYJ&oauth_callback=http%3A%2F%2Flocal%3Fdump&oauth_signature_method=HMAC-SHA1&oauth_signature=qZyTwVA48RzmtCHvN9mYWmlmSVU%3D

So we would need a full oauth implementation...

Why not just use https://github.com/vongrippen/bitbucket? Install the bitbucket gem and use the API to deploy.

@7h3kk1d
Copy link

7h3kk1d commented Aug 18, 2014

+1

@c10l
Copy link
Owner

c10l commented Aug 18, 2014

@kidovate I might have a look at that. It's worth noting, though that the maintainer has dropped support for that gem.

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

No branches or pull requests

7 participants