Access tokens for command line use

Issue #10182 resolved
Graham Lyon
created an issue

Currently I'm writing a set of scripts to streamline deployments at my place of work.

We use bitbucket for our source control and I'd like to do some calls to the REST API to verify certain things from the script before it runs. I'd rather not embed a username/password combo in this script for obvious reasons, and OAuth is out of the question as it cannot be used in an unattended manner.

What I'd like is the ability to generate access tokens in a similar manner that GitHub allows[1] - sorry to draw the comparison here, but it's a nice example of almost exactly what I'd like to have. The token need only be valid for the particular account/team account which generates it, without the added complexity which OAuth entails.

Would you consider adding support for this kind of workflow to Bitbucket?


Comments (10)

  1. Erik van Zijst

    OAuth is out of the question as it cannot be used in an unattended manner

    What do you mean by that? OAuth 1's digital signing is certainly more of a hassle that Basic HTTP Auth in the sense that you need a library for it.

    However, you can definitely use OAuth 1 tokens in automated scripts. In that case you do not need to bother with Access Tokens or the 3-legged auth-dance. If you create an OAuth consumer on the account that you want to authenticate as, just use that key and secret in the client.

    This flow is sometimes referred to as 2-Legged or 0-Legged OAuth.

    Having said all that, there is another alternative. Bitbucket team accounts support token-based authentication. You can generate one under "API Key" in the team's admin page:

    api key — Bitbucket 2014-08-13 11-37-55 2014-08-13 11-38-07.png

    You can then use that token as a simple revokable password.

  2. dragon788

    Would also love to see single user. Got here trying to figure out how to clone via CLI because I'm forced to use HTTPS behind the corporate firewall (no 22 out and therefore no git://) and I've enabled two factor and am therefore unable to use my regular HTTPS credentials. Github solves this with personal tokens, really hope that comes to BitBucket soon.

  3. Log in to comment