Build the OAuth2::Client object to be used when building an AccessToken.
19791
def client
      @client ||= ::OAuth2::Client.new(GoogleAPI.client_id, GoogleAPI.client_secret,
        site: 'https://accounts.google.com',
        token_url: '/o/oauth2/token',
        raise_errors: false
      )
    end
1096141
def accessors(options = {})
      headers = extract_headers!(options)
      json = client.list("/v1/auth/token/accessors", options, headers)
      return Secret.decode(json)
    end
789253
def _constructClient(client_version, username, user_domain, password, project_name, project_domain,
                         auth_url):
        """"""
        loader = loading.get_plugin_loader('password')

        # These only work with v3
        if user_domain is not None or project_domain is not None:
            auth = loader.load_from_options(auth_url=auth_url, username=username, user_domain_name=user_domain,
                                            password=password, project_name=project_name, project_domain_name=project_domain)
        else:
            auth = loader.load_from_options(auth_url=auth_url, username=username,
                                            password=password, project_name=project_name)

        sess = session.Session(auth=auth)
        return client.Client(client_version, session=sess)
1233088
public function getAccessToken()
    {
        try {
            $response = $this->post('/oauth/token')->send();
        } catch (ClientErrorResponseException $e) {
            throw OauthException::factory($e->getRequest(), $e->getResponse());
        }
        return new AccessToken($this, $response);
    }
1041040
public function getOAuthClient($client_id, $client_secret, $redirect_uri)
    {
        $options = [
            'clientId' => $client_id,
            'clientSecret' => $client_secret,
            'redirectUri' => $redirect_uri
        ];
        $OAuthClient = new OAuth($options);

        return $OAuthClient;
    }
851081
public function getOAuth2Client()
    {
        if (!$this->oAuth2Client instanceof OAuth2Client) {
            return new OAuth2Client(
                $this->getApp(),
                $this->getClient(),
                $this->getRandomStringGenerator()
            );
        }

        return $this->oAuth2Client;
    }
32505
def construct_oauth_url(self):
        
        response = self._requester(requests.head, 
                                   "{0}://{1}/".format(self.protocol, self.client.server),
                                   allow_redirects=False
                                  )
        if response.is_redirect:
            server = response.headers['location']
        else:
            server = response.url

        path = "oauth/authorize?oauth_token={token}".format(
            token=self.store["oauth-request-token"]
        )
        return "{server}{path}".format(
            server=server,
            path=path
        )
163190
public function findByAccessToken($accessToken)
    {
        if ($accessToken === '') {
            $client = new AnonymousClient();

            $this->clients[$client->getAccessToken()] = $client;

            return $client;
        }

        if (! isset($this->clients[$accessToken])) {

            return null;
        }

        return $this->clients[$accessToken];
    }
827414
private RegistryAuth authForAccessToken(final AccessToken accessToken) {
    return RegistryAuth.builder()
        .username("oauth2accesstoken")
        .password(accessToken.getTokenValue())
        .build();
  }
624269
def build_api_access_required(f):
    
    @functools.wraps(f)
    def wrapped(*args, **kwargs):
        g.api_key, g.build = can_api_key_access_build('build_id')
        return f(*args, **kwargs)
    return wrapped
755825
def authorize(credentials, client_class=Client):
    
    client = client_class(auth=credentials)
    client.login()
    return client
743945
def oauth_token_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/oauth/tokens.json"
        return self.call(api_path, method="POST", data=data, **kwargs)
1264976
public function getOAuth2Client()
    {
        if (!$this->oAuth2Client instanceof OAuth2Client) {
            $app = $this->getApp();
            $client = $this->getClient();
            $this->oAuth2Client = new OAuth2Client($app, $client, $this->getDefaultApiVersion());
        }

        return $this->oAuth2Client;
    }
1343034
def get_access_token(self, code, client_id, client_secret):
        ''' 
        
        '''
        headers = {
                'Content-Type' : 'application/json'
                }
        data = {
                'client_id' : client_id,
                'client_secret' : client_secret,
                'code' : code,
                }
        str_data = json.dumps(data)
        response = requests.request(method='POST', url=ACCESS_TOKEN_URL, headers=headers, data=str_data)
        status_code = response.status_code
        if status_code != 200:
            raise ValueError("{} -- {}".format(status_code, response.json()))
        return body['access_token']
1144421
def callback_oauth2(self, request):
        
        callback_url = self.callback_url(request)

        oauth = OAuth2Session(client_id=self.consumer_key, redirect_uri=callback_url, scope=self.scope)
        request_token = oauth.fetch_token(self.REQ_TOKEN,
                                          code=request.GET.get('code', ''),
                                          authorization_response=callback_url,
                                          client_secret=self.consumer_secret,
                                          scope=self.scope,
                                          verify=False)
        return request_token.get('access_token')
335680
public String build(Protocol protocol, String oauthToken, String oauthTokenSecret)
      throws IOException, OAuthException, URISyntaxException {
    OAuthAccessor accessor = new OAuthAccessor(consumer);
    accessor.tokenSecret = oauthTokenSecret;

    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put(OAuth.OAUTH_SIGNATURE_METHOD, "HMAC-SHA1");
    parameters.put(OAuth.OAUTH_TOKEN, oauthToken);

    String url = String.format("https://mail.google.com/mail/b/%s/%s/", email,
        (Protocol.IMAP == protocol) ? "imap" : "smtp");

    OAuthMessage message = new OAuthMessage(
        "GET",
        url,
        parameters.entrySet());
    message.addRequiredParameters(accessor);

    StringBuilder authString = new StringBuilder();
    authString.append("GET ");
    authString.append(url);
    authString.append(" ");
    int i = 0;
    for (Map.Entry<String, String> entry : message.getParameters()) {
      if (i++ > 0) {
        authString.append(",");
      }
      authString.append(OAuth.percentEncode(entry.getKey()));
      authString.append("=\"");
      authString.append(OAuth.percentEncode(entry.getValue()));
      authString.append("\"");
    }

    return Base64.encode(authString.toString().getBytes());
  }
956844
def create_client(access_token):
    """"""
    url = 'http://keycloak:8080/auth/admin/realms/dci-test/clients'
    r = requests.post(url,
                      data=json.dumps(client_data),
                      headers=get_auth_headers(access_token))
    if r.status_code in (201, 409):
        print('Keycloak client dci created successfully.')
    else:
        raise Exception(
            'Error while creating Keycloak client dci:\nstatus code %s\n'
            'error: %s' % (r.status_code, r.content)
        )