These instructions are for Confluence Server/Data Center. If you’re using Confluence Cloud, this use case is handled automatically.

Credentials

You can use two 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)

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).

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