Example #1
0
 /**
  * Authenticates a user.
  *
  * @param array       $credentials BitBucket authentication credentials
  * @param null|string $authMethod  One of the AUTH_* class constants
  */
 public function authenticate($credentials, $authMethod = self::AUTH_HTTP_PASSWORD)
 {
     if ($authMethod === self::AUTH_HTTP_PASSWORD) {
         $listener = new BasicAuthListener($credentials['username'], $credentials['password']);
     } else {
         $listener = new OAuthListener(['oauth_consumer_key' => $credentials['key'], 'oauth_consumer_secret' => $credentials['secret']]);
     }
     $this->httpClient->addListener($listener);
 }