protected function getBitbucketAccessToken(array $credentials)
    {
        if (isset($this->bitbucketAccessTokens[$credentials['key']])) {
            return $this->bitbucketAccessTokens[$credentials['key']];
        }
        $result = $this->api()
            ->getHttpClient()
            ->post('https://bitbucket.org/site/oauth2/access_token', [
                'auth' => [$credentials['key'], $credentials['secret']],
                'body' => [
                    'grant_type' => 'client_credentials',
                ],
            ]);

        $data = $result->json();
        if (!isset($data['access_token'])) {
            throw new \RuntimeException('Access token not found in Bitbucket response');
        }

        $this->bitbucketAccessTokens[$credentials['key']] = $data['access_token'];

        return $data['access_token'];
    }
protected function getBitbucketAccessToken(array $credentials)
    {
        if (isset($this->bitbucketAccessTokens[$credentials['key']])) {
            return $this->bitbucketAccessTokens[$credentials['key']];
        }
        $result = $this->api()
            ->getHttpClient()
            ->post('https://bitbucket.org/site/oauth2/access_token', [
                'auth' => [$credentials['key'], $credentials['secret']],
                'body' => [
                    'grant_type' => 'client_credentials',
                ],
            ]);

        $data = $result->json();
        if (!isset($data['access_token'])) {
            throw new \RuntimeException('Access token not found in Bitbucket response');
        }

        $this->bitbucketAccessTokens[$credentials['key']] = $data['access_token'];

        return $data['access_token'];
    }
protected function getBitbucketAccessToken ( array $ credentials ) { if ( isset ( $ this -> bitbucketAccessTokens [ $ credentials [ 'key' ] ] ) ) { return $ this -> bitbucketAccessTokens [ $ credentials [ 'key' ] ] ; } $ result = $ this -> api ( ) -> getHttpClient ( ) -> post ( 'https://bitbucket.org/site/oauth2/access_token' , [ 'auth' => [ $ credentials [ 'key' ] , $ credentials [ 'secret' ] ] , 'body' => [ 'grant_type' => 'client_credentials' , ] , ] ) ; $ data = $ result -> json ( ) ; if ( ! isset ( $ data [ 'access_token' ] ) ) { throw new \ RuntimeException ( 'Access token not found in Bitbucket response' ) ; } $ this -> bitbucketAccessTokens [ $ credentials [ 'key' ] ] = $ data [ 'access_token' ] ; return $ data [ 'access_token' ] ; }
Obtain an OAuth2 token for Bitbucket from the given app credentials.

@param array $credentials

@return string
Obtain an OAuth2 token for Bitbucket from the given app credentials .