Sets the oauth_client attribute
1665
def set_oauth_client(self, consumer_key, consumer_secret):
        
        self.oauth_client = oauth1.Client(consumer_key, consumer_secret)
1123369
def set_credentials(self, client_id=None, client_secret=None):
        
        self._client_id = client_id
        self._client_secret = client_secret

        # make sure to reset session due to credential change
        self._session = None
1196784
def _store_oauth_access_token(self, oauth_access_token):
        ''' 
        '''
        c = Cookie(version=0, name='oauth_access_token', value=oauth_access_token,
            port=None, port_specified=False,
            domain='steamwebbrowser.tld', domain_specified=True, domain_initial_dot=False,
            path='/', path_specified=True,
            secure=False, expires=None, discard=False, comment=None, comment_url=None, rest={},
        )
        self.session.cookies.set_cookie(c)
        self._save_cookies()
962613
def require_api_auth(allow_anonymous=False):
    
    def wrapper(f):
        """Wrap function with oauth require decorator."""
        f_oauth_required = oauth2.require_oauth()(f)

        @wraps(f)
        def decorated(*args, **kwargs):
            """Require OAuth 2.0 Authentication."""
            if not hasattr(current_user, 'login_via_oauth2'):
                if not current_user.is_authenticated:
                    if allow_anonymous:
                        return f(*args, **kwargs)
                    abort(401)
                if current_app.config['ACCOUNTS_JWT_ENABLE']:
                    # Verify the token
                    current_oauth2server.jwt_veryfication_factory(
                        request.headers)
                # fully logged in with normal session
                return f(*args, **kwargs)
            else:
                # otherwise, try oauth2
                return f_oauth_required(*args, **kwargs)
        return decorated
    return wrapper
43021
def get_client(self, request=None):
        """"""

        if not isinstance(request, oauth.Request):
            request = self.get_oauth_request()
        client_key = request.get_parameter('oauth_consumer_key')
        if not client_key:
            raise Exception('Missing "oauth_consumer_key" parameter in ' \
                'OAuth "Authorization" header')

        client = models.Client.get_by_key_name(client_key)
        if not client:
            raise Exception('Client "%s" not found.' % client_key)

        return client
1039615
def grant_client(self, client_id):
        
        zone = self.service.settings.data['zone']['oauth-scope']

        scopes = ['openid', zone,
                  'acs.policies.read', 'acs.attributes.read',
                  'acs.policies.write', 'acs.attributes.write']

        authorities = ['uaa.resource', zone,
                  'acs.policies.read', 'acs.policies.write',
                  'acs.attributes.read', 'acs.attributes.write']

        self.service.uaa.uaac.update_client_grants(client_id, scope=scopes,
                authorities=authorities)

        return self.service.uaa.uaac.get_client(client_id)
1344401
protected function setApiClient()
    {
        $apiDomain = "https://{$this->domain}";

        $client = new ApiClient(
            [
                'domain' => $apiDomain,
                'basePath' => '/',
                'guzzleOptions' => $this->guzzleOptions
            ]
        );

        $this->apiClient = $client;
    }
1040838
def org_set_member_access(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/setMemberAccess' % object_id, input_params, always_retry=always_retry, **kwargs)
1325975
def _set_format_oauth(self):
        
        format_oauth = urllib.parse.urlencode({
            'client_id': self._client_id,
            'client_secret': self._client_secret,
            'scope': self._url_request,
            'grant_type': self._grant_type
        }).encode("utf-8")
        return format_oauth
946765
def setup_oauth_client(self, url=None):
        
        if url and "://" in url:
            server, endpoint = self._deconstruct_url(url)
        else:
            server = self.client.server

        if server not in self._server_cache:
            self._add_client(server)

        if server == self.client.server:
            self.oauth = OAuth1(
                client_key=self.store["client-key"],
                client_secret=self.store["client-secret"],
                resource_owner_key=self.store["oauth-access-token"],
                resource_owner_secret=self.store["oauth-access-secret"],
            )
            return self.oauth
        else:
            return OAuth1(
                client_key=self._server_cache[server].key,
                client_secret=self._server_cache[server].secret,
            )
1306934
def set_attributes_for exc, request
      self.backtrace      = exc.backtrace.join("\n"),
      self.request_url    = request.original_url,
      self.request_method = request.request_method,
      self.parameters     = request.filtered_parameters,
      self.user_agent     = request.user_agent,
      self.client_ip      = request.remote_ip,
      self.status         = "new",
      self.description    = exc.inspect
    end
427635
def authorize_client_credentials(
        self, client_id, client_secret=None, scope="private_agent"
    ):
        
        self.auth_data = {
            "grant_type": "client_credentials",
            "scope": [ scope ],
            "client_id": client_id,
            "client_secret": client_secret
        }

        self._do_authorize()
711031
def _authenticate_client(self, client, secret):
        
        client_s = str.join(':', [client, secret])
        credentials = base64.b64encode(client_s.encode('utf-8')).decode('utf-8')

        headers = {
            'Content-Type': 'application/x-www-form-urlencoded',
            'Cache-Control': 'no-cache',
            'Authorization': 'Basic ' + credentials
            }
        params = {
            'client_id': client,
            'grant_type': 'client_credentials'
            }
        uri = self.uri + '/oauth/token'

        logging.debug("URI=" + str(uri))
        logging.debug("HEADERS=" + str(headers))
        logging.debug("BODY=" + str(params))

        response = requests.post(uri, headers=headers, params=params)
        if response.status_code == 200:
            logging.debug("RESPONSE=" + str(response.json()))
            return response.json()
        else:
            logging.warning("Failed to authenticate as %s" % (client))
            response.raise_for_status()
426946
def client
      @client ||= begin
        client = Google::APIClient.new
        client.authorization = Signet::OAuth2::Client.new(
          token_credential_uri: 'https://accounts.google.com/o/oauth2/token',
          audience: 'https://accounts.google.com/o/oauth2/token',
          scope: 'https://www.googleapis.com/auth/analytics.readonly',
          issuer: Gxapi.config.google.email,
          signing_key: self.get_key
        )
        client.authorization.fetch_access_token!
        client
      end
    end
587481
def request(self, method, url, **kwargs):
        ""
        user_token = kwargs.pop('token', self.token)
        token, _ = self.parse_raw_token(user_token)
        if token is not None:
            params = kwargs.get('params', {})
            params['access_token'] = token
            kwargs['params'] = params
        return super(OAuth2Client, self).request(method, url, **kwargs)
1172487
def save_oauth_session
      super
      auth_session[:auth_attributes] = attributes.reject!{|k, v| v.blank? || !self.respond_to?(k)} unless is_auth_session?
    end
907480
def update_attributes_from_token(access_token)
        @expires_at               = Time.now + access_token.params[:oauth_expires_in].to_i
        @authorization_expires_at = Time.now + access_token.params[:oauth_authorization_expires_in].to_i
        @session_handle           = access_token.params[:oauth_session_handle]
        @atoken, @asecret         = access_token.token, access_token.secret
        @access_token             = nil
      end