Configuring OAuth 2.0 for the Bitbucket Cloud

You can enable users to work with a remote Git repository that is hosted in the Bitbucket Cloud:

  1. Set up an OAuth consumer (OAuth 2.0) in the Bitbucket Cloud.

  2. Apply an OAuth consumer Secret for the Bitbucket Cloud.

Setting up an OAuth consumer in the Bitbucket Cloud

Set up an OAuth consumer for OAuth 2.0 in the Bitbucket Cloud.

Prerequisites
  • You are logged in to the Bitbucket Cloud.

  • base64 is installed in the operating system you are using.

Procedure
  1. Click your avatar and go to the All workspaces page.

  2. Select a workspace and click it.

  3. Go to Settings  OAuth consumers  Add consumer.

  4. Enter Che as the Name.

  5. Enter https://<che_fqdn>/api/oauth/callback as the Callback URL.

  6. Under Permissions, check all of the Account and Repositories checkboxes, and click Save.

  7. Expand the added consumer and then copy the Key value and encode it to Base64 for use when applying the Bitbucket OAuth consumer Secret:

    $ echo -n '<bitbucket_oauth_consumer_key>' | base64
  8. Copy the Secret value and encode it to Base64 for use when applying the Bitbucket OAuth consumer Secret:

    $ echo -n '<bitbucket_oauth_consumer_secret>' | base64

Applying an OAuth consumer Secret for the Bitbucket Cloud

Prepare and apply an OAuth consumer Secret for the Bitbucket Cloud.

Prerequisites
  • The OAuth consumer is set up in the Bitbucket Cloud.

  • The Base64-encoded values, which were generated when setting up the Bitbucket OAuth consumer, are prepared:

    • Bitbucket OAuth consumer Key

    • Bitbucket OAuth consumer Secret

  • An active kubectl session with administrative permissions to the destination Kubernetes cluster. See Overview of kubectl.

Procedure
  1. Prepare the Secret:

    kind: Secret
    apiVersion: v1
    metadata:
      name: bitbucket-oauth-config
      namespace: eclipse-che (1)
      labels:
        app.kubernetes.io/part-of: che.eclipse.org
        app.kubernetes.io/component: oauth-scm-configuration
      annotations:
        che.eclipse.org/oauth-scm-server: bitbucket
    type: Opaque
    data:
      id: <Base64_Bitbucket_Oauth_Consumer_Key> (2)
      secret: <Base64_Bitbucket_Oauth_Consumer_Secret> (3)
    1 The Che namespace. The default is eclipse-che.
    2 The Base64-encoded Bitbucket OAuth consumer Key.
    3 The Base64-encoded Bitbucket OAuth consumer Secret.
  2. Apply the Secret:

    $ kubectl apply -f - <<EOF
    <Secret_prepared_in_the_previous_step>
    EOF
  3. Verify in the output that the Secret is created.