Credentials

You can use 3 options to access file content:

  1. Use real Bitbucket account (which is not recommended for security reasons)  
  2. Use App passwords (https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html)
  3. Use OAuth token (https://confluence.atlassian.com/bitbucket/oauth-on-bitbucket-cloud-238027431.html)

Only permission required for OAuth customer or App password is Repository Read

App passwords and regular credentials should be entered in user/password fields (Username is the actual user name in both cases).

OAuth token should go to the Token field (and other fields should left blank)

How to get an Oauth token

  1. Create OAuth customer on Bitbucket settings page
  2. Open https://bitbucket.org/site/oauth2/authorize?client_id={key}&response_type=token (replace {key} with the key generated on step #1)
  3. Once you get re-directed grab access_token parameter from browser address bar and replace trailing %3D with =
  4. Use access token on Host Credentials screen on your Confluence.

You may need to renew the access token eventually.

URL to use

Unfortunately, raw links  (which are provided in the user interface)  don't work correctly with OAuth and App passwords (as of April 2019).

You should use links to api.bitbucket.org :

https://api.bitbucket.org/2.0/repositories/<owner>/<repo-key>/src/<commit-or-branch>/<path-to-file>

Example is:

https://api.bitbucket.org/2.0/repositories/andrl/test-repo/src/master/rst/cmd.md