Create an UberRidesClient from OAuth 2.0 credentials.

    Parameters
        credentials (dict)
            Dictionary of OAuth 2.0 credentials.

    Returns
        (UberRidesClient)
            An authorized UberRidesClient to access API resources.
163310
def create_uber_client(credentials):
    
    oauth2credential = OAuth2Credential(
        client_id=credentials.get('client_id'),
        access_token=credentials.get('access_token'),
        expires_in_seconds=credentials.get('expires_in_seconds'),
        scopes=credentials.get('scopes'),
        grant_type=credentials.get('grant_type'),
        redirect_url=credentials.get('redirect_url'),
        client_secret=credentials.get('client_secret'),
        refresh_token=credentials.get('refresh_token'),
    )
    session = Session(oauth2credential=oauth2credential)
    return UberRidesClient(session, sandbox_mode=True)
971019
def Credentials(self):
		

		return(clc.v2.API.Call('GET','servers/%s/%s/credentials' % (self.alias,self.name),session=self.session))
1370302
def get_access_token(self, code=None, **params):
        
        if self._access_token is None:
            if code is None:
                raise ValueError(_('Invalid code.'))
            
            self.access_token_dict = self._get_access_token(code, **params)
            try:
                self._access_token = self.access_token_dict['access_token']
            except KeyError, e:
                raise OAuthError("Credentials could not be validated, the provider returned no access token.")
                
        return self._access_token
1338462
function _authEvrythng(credentials) {
    var $this = this;

    return EVT.api({
      url: '/auth/evrythng',
      method: 'post',
      data: credentials,
      authorization: this.apiKey
    }).then(function (access) {

      // Once it is authenticated, get this user information as well.
      return EVT.api({
        url: '/users/' + access.evrythngUser,
        authorization: access.evrythngApiKey
      }).then(function (userInfo) {

        // Keep nested success handler because we also need the *access*
        // object returned form the previous call to create the User Scope.
        var userObj = Utils.extend(userInfo, {
          id: access.evrythngUser,
          apiKey: access.evrythngApiKey
        });

        // Create User Scope
        var user = new EVT.User(userObj, $this);

        return { user: user };

      });

    });
  }
310235
def _get_credentials(self):
        
        client_secret_path = os.path.dirname(self.client_secret)
        auth_token_path = os.path.dirname(self.auth_token)

        if not os.path.exists(auth_token_path):
            os.makedirs(auth_token_path)

        if not os.path.exists(client_secret_path):
            os.makedirs(client_secret_path)

        flags = tools.argparser.parse_args(args=[])
        store = Storage(self.auth_token)
        credentials = store.get()

        if not credentials or credentials.invalid:
            try:
                flow = client.flow_from_clientsecrets(self.client_secret, SCOPES)
                flow.user_agent = APPLICATION_NAME
                if flags:
                    credentials = tools.run_flow(flow, store, flags)
                else:  # Needed only for compatibility with Python 2.6
                    credentials = tools.run(flow, store)
            except clientsecrets.InvalidClientSecretsError:
                raise Exception("missing client_secret")
            """
            Have to restart i3 after getting credentials to prevent bad output.
            This only has to be done once on the first run of the module.
            """
            self.py3.command_run("{} restart".format(self.py3.get_wm_msg()))

        return credentials
1367563
def generate_edit_credentials(self):
        
        params = {
            'action': 'query',
            'meta': 'tokens',
            'format': 'json'
        }
        response = self.s.get(self.base_url, params=params)
        self.edit_token = response.json()['query']['tokens']['csrftoken']

        return self.s.cookies
1021589
def requires_app_credentials(func):
    
    @wraps(func)
    def auth_wrapper(self, *args, **kwargs):
        client_id, client_secret = self._session.retrieve_client_credentials()
        if client_id and client_secret:
            return func(self, *args, **kwargs)
        else:
            from .models import GitHubError
            # Mock a 401 response
            r = generate_fake_error_response(
                '{"message": "Requires username/password authentication"}'
            )
            raise GitHubError(r)

    return auth_wrapper
450349
def create_token(credential, opts = {})
      data, _status_code, _headers = create_token_with_http_info(credential, opts)
      return data
    end
969087
def connect():
    """"""

    # Exchange authorization code for acceess token and create session
    session = auth_flow.get_session(request.url)
    client = UberRidesClient(session)

    # Fetch profile for driver
    profile = client.get_driver_profile().json

    # Fetch last 50 trips and payments for driver
    trips = client.get_driver_trips(0, 50).json
    payments = client.get_driver_payments(0, 50).json

    return render_template('driver_dashboard.html',
                           profile=profile,
                           trips=trips['trips'],
                           payments=payments['payments']
                           )
721162
def credentials(self):
        
        if self._credentials is None:
            self._credentials = CredentialList(self)
        return self._credentials
877068
def create_request_token(self, request, credentials):
        
        token = {
            'oauth_token': self.token_generator(),
            'oauth_token_secret': self.token_generator(),
            'oauth_callback_confirmed': 'true'
        }
        token.update(credentials)
        self.request_validator.save_request_token(token, request)
        return urlencode(token.items())
4520
def get_auth_instance(credentials, auth_type):
    
    model = AUTH_TYPE_MAP[auth_type]
    if model is None:
        return None
    username = credentials.username
    if auth_type == NTLM and credentials.type == credentials.EMAIL:
        username = '\\' + username
    if auth_type == GSSAPI:
        # Kerberos auth relies on credentials supplied via a ticket available externally to this library
        return model()
    return model(username=username, password=credentials.password)
884351
async def generate_credentials(self):
        
        identifier, seed = new_credentials()
        return '{0}:{1}'.format(identifier, seed.decode().upper())
1285555
def retrieve_client_credentials(self):
        
        client_id = self.params.get('client_id')
        client_secret = self.params.get('client_secret')
        return (client_id, client_secret)
31074
private static BasicCredentials createServiceCredentials(AuthleteConfiguration configuration)
    {
        // API key and API secret of a Service.
        String key    = configuration.getServiceApiKey();
        String secret = configuration.getServiceApiSecret();

        return new BasicCredentials(key, secret);
    }
1220969
def set_credentials(username, api_key=None, password=None, region=None,
        tenant_id=None, authenticate=True):
    
    global regions, services
    pw_key = password or api_key
    region = _safe_region(region)
    tenant_id = tenant_id or settings.get("tenant_id")
    identity.set_credentials(username=username, password=pw_key,
            tenant_id=tenant_id, region=region, authenticate=authenticate)
    regions = tuple(identity.regions)
    services = tuple(identity.services.keys())
    connect_to_services(region=region)
563376
def login(self, identity, credentials):
        '''
        '''
        result = self.dispatcher.session.post(self._url('v0/auth/login'),
                                              json={
                                                  'email': identity,
                                                  'password': credentials
                                              })
        status = result.status_code
        if status == 400:
            raise APIException('invalid parameters, login process has changed')
        elif status == 401:
            # do our best to get something out to the user
            msg = result.text
            try:
                msg = json.loads(result.text)['message']
            finally:
                raise InvalidIdentity(msg)
        elif status != 200:
            raise APIException('%s: %s' % (status, result.text))
        jwt = result.text
        payload = jwt.split('.')[1]
        rem = len(payload) % 4
        if rem > 0:
            payload += '=' * (4 - rem)
        payload = base64.urlsafe_b64decode(payload.encode('utf-8'))
        return json.loads(payload.decode('utf-8'))