BitbucketClient

A Swift client for the Bitbucket API. Bitbucket’s OAI specification schema is also documented in Swagger.

Authentication

The credentials required to authenticate with the Bitbucket API are private. Authentication is (currently) implemented using “Basic” HTTP Authentication as per RFC-2617 with a username and password pair. A bitbucket-credentials.json JSON file should be created in the root project directory (where the Package.swift is located).

The JSON should be of the following form:

{
    "username": "<your-bitbucket-username>",
    "password": "<your-app-password>"
}

Where:

  • username: Your Bitbucket username, can be found under “Personal Settings > Account Settings”
  • password: A (personal) “App Password”, you might need to create a new one for this

This file is not checked in to Git.

OAuth Bitbucket App

Later on, for instance if a UI is added to this client, we should consider migrating to OAuth authentication. This would involve creating a Bitbucket App under the 3 Sided Cube workspace. There is already a bitbucket-descriptor.json file in the project, that will need updating.

To get the clientId and secret:

  1. Open Bitbucket and click on your avatar (in the top right)
  2. Open the “3” (for 3 Sided Cube) workspace in Bitbucket (may need to select “All workspaces”)
  3. Click on “Settings”
  4. Click on “Develop Apps”

There you will be able to get the clientId and secret for this client. For more information on adding a Bitbucket App please see Integrating with Bitbucket Cloud.

File Structure

The data loaded from the API is cached. This is to save fetching from the API each time when running, say, statistical queries. The file/directory structure is as follows:

- BitbucketClientCache
  {workspaceId}.json // Workspace
  users.json // [User]
  repositories.json // [Repository]
  - {RepositoryId1}
    pullRequests.json // [PullRequest]
    - {PullRequestId1}
      comments.json // [Comment]
    ...
  ...

GitHub

View Github