Use an authorized client to fetch and print profile information.

    Parameters
        api_client (UberRidesClient)
            An UberRidesClient with OAuth 2.0 credentials.
505896
def hello_user(api_client):
    

    try:
        response = api_client.get_user_profile()

    except (ClientError, ServerError) as error:
        fail_print(error)
        return

    else:
        profile = response.json
        first_name = profile.get('first_name')
        last_name = profile.get('last_name')
        email = profile.get('email')
        message = 'Hello, {} {}. Successfully granted access token to {}.'
        message = message.format(first_name, last_name, email)
        success_print(message)
        success_print(profile)

        success_print('---')
        response = api_client.get_home_address()
        address = response.json
        success_print(address)

        success_print('---')
        response = api_client.get_user_activity()
        history = response.json
        success_print(history)
872282
def client_info(self, client):
        
        client = self._client_id(client)
        response = self._get(url.clients_id.format(id=client))
        self._check_response(response, 200)
        return self._create_response(response)
836400
def api(name, url, token, **kwargs):
    """"""
    return Client(token).api(name, url, **kwargs)
128966
def _get_client(profile):
    '''
    
    '''
    token = _get_config_value(profile, 'token')
    key = 'github.{0}:{1}'.format(
        token,
        _get_config_value(profile, 'org_name')
    )

    if key not in __context__:
        __context__[key] = github.Github(
            token,
            per_page=100
        )
    return __context__[key]
81422
def oauth_client_create(self, name, redirect_uri, **kwargs):
        
        params = {
            "label": name,
            "redirect_uri": redirect_uri,
        }
        params.update(kwargs)

        result = self.client.post('/account/oauth-clients', data=params)

        if not 'id' in result:
            raise UnexpectedResponseError('Unexpected response when creating OAuth Client!',
                    json=result)

        c = OAuthClient(self.client, result['id'], result)
        return c
40236
function getProfile(provider, access_token, callback) {
  let fields;
  switch (provider) {
    case 'facebook':
      facebook.query().get('me?fields=name,email').auth(access_token).request(function (err, res, body) {
        if (err) {
          callback(err);
        } else {
          callback(null, {
            username: body.name,
            email: body.email
          });
        }
      });
      break;
    case 'google':
      google.query('plus').get('people/me').auth(access_token).request(function (err, res, body) {
        if (err) {
          callback(err);
        } else {
          callback(null, {
            username: body.displayName,
            email: body.emails[0].value
          });
        }
      });
      break;
    case 'github':
      github.query().get('user').auth(access_token).request(function (err, res, body) {
        if (err) {
          callback(err);
        } else {
          callback(null, {
            username: body.login,
            email: body.email
          });
        }
      });
      break;
    case 'linkedin2':
      fields = [
        'public-profile-url', 'email-address'
      ];
      linkedin.query().select('people/~:(' + fields.join() + ')?format=json').auth(access_token).request(function (err, res, body) {
        if (err) {
          callback(err);
        } else {
          callback(null, {
            username: substr(body.publicProfileUrl.lastIndexOf('/') + 1),
            email: body.emailAddress
          });
        }
      });
      break;
    default:
      callback({
        message: 'Unknown provider.'
      });
      break;
  }
}
816702
function (req, res) {
  return rp({
    method: 'POST',
    uri: config.LYFT_API_URI + '/oauth/token',
    auth: {
      username: config.LYFT_CLIENT_ID,
      password: (config.USE_SANDBOX ? 'SANDBOX-' : '') + config.LYFT_CLIENT_SECRET
    },
    json: {
      grant_type: 'client_credentials',
      scope: 'public'
    }
  })
}
1315014
def hello_user(api_client):
    

    try:
        response = api_client.get_user_profile()

    except (ClientError, ServerError) as error:
        fail_print(error)
        return

    else:
        profile = response.json
        user_id = profile.get('id')
        message = 'Hello. Successfully granted access token to User ID {}.'.format(user_id)
        success_print(message)
688317
def _do_authorize(self):
        
        if self.auth_data is None:
            raise ApiwatcherClientException("You must provide authorization data.")

        r = requests.post(
            "{0}/api/token".format(self.base_url), json=self.auth_data,
            verify=self.verify_certificate, timeout=self.timeout
        )

        if r.status_code == 401:
            raise ApiwatcherClientException("Wrong credentials supplied: {0}".format(
                r.json()["message"]
            ))
        elif r.status_code != 201:
            try:
                reason = r.json()["message"]
            except:
                reason = r.text
            raise ApiwatcherClientException(
                "Authorization failed. Reason {0} {1}".format(
                    r.status_code, reason)
                )
        else:
            data = r.json()["data"]
            self.token = data["access_token"]

            if "refresh_token" in data:
                self.auth_data = {
                    "grant_type": "refresh_token",
                    "refresh_token": data["refresh_token"],
                    "client_id": self.auth_data["client_id"]
                }
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)
1144086
def authenticate(cls, client_id, secret):
        
        result = yield views.oauth_client.get(key=[secret, client_id])
        if not result['rows']:
            raise Return()

        service = yield Service.get(client_id)
        raise Return(service)
1287035
def _verify_client_authentication(self, request_body, http_headers=None):
        # type (str, Optional[Mapping[str, str]] -> Mapping[str, str]
        
        if http_headers is None:
            http_headers = {}
        token_request = dict(parse_qsl(request_body))
        token_request['client_id']  = verify_client_authentication(self.clients, token_request, http_headers.get('Authorization'))
        return token_request
197697
@RequestMapping(value = "/api/profile/{profileIdentifier}/clients/{clientUUID}", method = RequestMethod.GET)
    public
    @ResponseBody
    HashMap<String, Object> getClient(Model model,
                                      @PathVariable("profileIdentifier") String profileIdentifier,
                                      @PathVariable("clientUUID") String clientUUID) throws Exception {
        Integer profileId = ControllerUtils.convertProfileIdentifier(profileIdentifier);
        HashMap<String, Object> valueHash = new HashMap<String, Object>();
        valueHash.put("client", clientService.findClient(clientUUID, profileId));
        return valueHash;
    }
1016526
def get_clients(self):
        
        self.assert_has_permission('clients.read')

        uri = self.uri + '/oauth/clients'
        headers = self.get_authorization_headers()
        response = requests.get(uri, headers=headers)
        return response.json()['resources']
684896
def _client(self, id, secret):
        """"""
        url = self.api_url + self.auth_token_url
        auth_string = '%s:%s' % (id, secret)
        authorization = base64.b64encode(auth_string.encode()).decode()
        headers = {
            'Authorization': "Basic " + authorization,
            'Content-Type': "application/x-www-form-urlencoded"
        }
        params = {
            'grant_type': 'client_credentials',
            'response_type': 'token'
        }
        return self.session.post(url, params=params, headers=headers)
1665
def set_oauth_client(self, consumer_key, consumer_secret):
        
        self.oauth_client = oauth1.Client(consumer_key, consumer_secret)
682194
def get(self, request, *args, **kwargs):
        
        serializer = self.serializer_reader_class
        if request.user.is_authenticated():
            return Response(serializer(request.user, context=self.get_serializer_context()).data)
        else:
            return Response({'detail': _('Authentication credentials were not provided')}, status=401)