Skip to content

Does install_bitbucket work with (new, required) API tokens with scopes? #844

Closed

Description

@tersmitten

App passwords has been replaced by API tokens. As of September 9, 2025, app passwords can no longer be created. It's required to use API tokens with scopes instead. All existing app passwords will be disabled on June 9, 2026.

I used to install (private) packages from Bitbucket using devtools::install_bitbucket with the environment variables BITBUCKET_USER (my username) and BITBUCKET_PASSWORD (a App password) filled in. Now that it's no longer possible to create new App passwords and they will stop working in a few months what are we supposed to use?

Does install_bitbucket already work with API tokens with scopes? Do I just replace my App password with a API token with scopes in the BITBUCKET_PASSWORD variable or is there more to it?

Thanks in advance.

Activity

  1. tersmitten commented on Feb 3, 2026

    @tersmitten
    Author
    Sys.setenv(BITBUCKET_USER = 'foo')
    Sys.setenv(BITBUCKET_PASSWORD = 'App password')
    
    devtools::install_bitbucket(repo = "bar/r-helpers")
    # works
    
    Sys.setenv(BITBUCKET_USER = 'foo')
    Sys.setenv(BITBUCKET_PASSWORD = 'API token with scopes')
    
    devtools::install_bitbucket(repo = "bar/r-helpers")
    # does not work
    #
    # Error: Failed to install 'unknown package' from Bitbucket:
    #  cannot open URL 'https://api.bitbucket.org/2.0/repositories/bar/r-helpers/src/HEAD/DESCRIPTION'
  2. tersmitten commented on Mar 13, 2026

    @tersmitten
    Author
    [Action required] App passwords deprecation notice
    

    I'm I the only one using Bitbucket, or is this project dead?

  3. tstev commented on Mar 26, 2026

    @tstev

    Hello Mischa!

    Unfortunately, imho, my work also uses Atlassian products including Bitbucket. I got this to work by setting auth_user to my Bitbucket email and BITBUCKET_PASSWORD to an API token with the following scopes:

    • read:respository:bitbucket
    • write:respository:bitbucket
    • read:pullrequest:bitbucket
    • write:pullrequest:bitbucket

    So this work for me again using remotes:

    remotes::install_bitbucket(
      "<workspace>/<repo>", 
      auth_user = "me@email.com"
    )

    Unfortunately using ref to select a particular branch like feature/new doesn't work and results in the same error you see. It works with main but I think - not sure - the slash in the branch name throws off the API? I worked around that by having a little helper function that converts the ref to a commit id and that works.

    Something along the lines of:

    httr2::request("https://api.bitbucket.org/2.0/repositories/<workspace>/<repo>/refs/branches/<ref>") |>
      httr2::req_auth_basic(Sys.getenv("BITBUCKET_EMAIL"), Sys.getenv("BITBUCKET_PASSWORD")) |>
      httr2::req_perform() |>
      httr2::resp_body_json() |>
      purrr::pluck("target", "hash")

    Hopefully this works for you too!

  4. tersmitten commented on Mar 26, 2026

    @tersmitten
    Author

    Thanks for adding your findings, I'll check if I can get it working like this too.

  5. tersmitten commented on Apr 27, 2026

    @tersmitten
    Author

    An API token with the scopes above also worked for me, but I needed to change Sys.setenv(BITBUCKET_USER = 'username') to Sys.setenv(BITBUCKET_USER = 'email-address'). No need to set auth_user = "me@email.com" in the install_bitbucket call.

  6. tersmitten commented on Apr 27, 2026

    @tersmitten
    Author
    1: `install_bitbucket()` was deprecated in devtools 2.5.0.
    ℹ Please use `remotes::install_bitbucket()` instead.
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions