Get auth data from the request. The token takes the precedence.
354853
def get_auth(required_role: Roles::USER)
        if params[:token]
          get_token(required_role: required_role)
        else
          get_api_key(required_role: required_role)
        end
      end
1373643
def get_token(self, code, headers=None, **kwargs):
        
        self._check_configuration("site", "token_url", "redirect_uri",
                                  "client_id", "client_secret")
        url = "%s%s" % (self.site, quote(self.token_url))
        data = {
            'redirect_uri': self.redirect_uri,
            'client_id': self.client_id,
            'client_secret': self.client_secret,
            'code': code,
        }
        data.update(kwargs)

        return self._make_request(url, data=data, headers=headers)
659214
def get_jwt(self, request):
        
        try:
            authorization = request.authorization
        except ValueError:
            return None
        if authorization is None:
            return None
        authtype, token = authorization
        if authtype.lower() != self.auth_header_prefix.lower():
            return None
        return token
1245591
def get(self, url=None, params=None, retry=True):
        '''
        
        '''
        headers = self._gen_headers(self.access_token, url)
        attempts = 1
        while attempts <= HTTP_ATTEMPTS_MAX:
            try:
                res = requests.get(url,
                                   headers=headers,
                                   params=params,
                                   timeout=15,
                                   verify=self.certs)
                res.raise_for_status()
                return res.json()
            except requests.exceptions.RequestException as e:
                attempts += 1
                if res.status_code in [400]:
                    raise e
                elif retry and res.status_code in [403]:
                    self.relogin_oauth2()
1356813
def token(self):
        
        prefixes = ("Bearer", "Token")
        auth_header = self.headers.get("Authorization")

        if auth_header is not None:
            for prefix in prefixes:
                if prefix in auth_header:
                    return auth_header.partition(prefix)[-1].strip()

        return auth_header
657643
def _get_token(self):
        '''
        
        '''
        self.session.token = self.request(
            'getCommunicationToken',
            {'secretKey': self.session.secret},
            {'uuid': self.session.user,
             'session': self.session.session,
             'clientRevision': grooveshark.const.CLIENTS['htmlshark']['version'],
             'country': self.session.country,
             'privacy': 0,
             'client': 'htmlshark'})[1]
        self.session.time = time.time()
788267
def get_token(self, token):
        '''
        
        '''
        load = {}
        load['token'] = token
        load['cmd'] = 'get_token'
        tdata = self._send_token_request(load)
        return tdata
31631
def get(self, request):
        ''''''
        user = request.user
        serializer = PermissionsUserSerializer(
            instance=user, context={'request': request})
        return Response(data=serializer.data)
962213
def get_token_and_data(self, data):
        '''
        
        '''
        token = ''
        for c in data:
            if c != ')':
                token = token + c
            else:
                break;

        return token, data.lstrip(token + '):')
750201
def access_token(self, request_token, request_secret):
        """"""
        logging.debug("Getting access token from %s:%d",
                      self.server, self.port)
        self.access_token, self.access_secret = \
            self._token("/oauth/accessToken", request_token, request_secret)
        return self.access_token, self.access_secret
459723
def _obtain_api_token(self, username, password):
        """"""
        data = self._request("POST", "auth/apitoken",
                             {"username": username, "password": password},
                             reestablish_session=False)
        return data["api_token"]
1232719
def _get_token(request):
    
    token = request.headers.get('Authorization')
    if not token:
        message = 'Token not in Authorization header'
        logging.warning(message)
        raise HTTPError(401, message)
    return token
98399
def retrieve_token(self):
        

        if self.authorization_code:
            request_param = {
                "client_id": self.client_id,
                "client_secret": self.client_secret,
                "redirect_uri": self.redirect_uri,
                "code": self.authorization_code
                }

            if self._extra_token_params:
                request_param.update(self._extra_token_params)

            content_length = len(urlencode(request_param))
            headers = {
                'Content-Length': str(content_length),
                'Content-Type': 'application/x-www-form-urlencoded'
                }
        
            r = requests.post(self.token_uri, data=request_param,
                              headers=headers)
            jsondata = json.loads(r.text)
            self.access_token = jsondata
            return self.access_token

        else:
            print("authorization code is required before getting accesss token")
            print("Please call retrieve_authorization_code() beforehand")
1126805
function () {
    // Get stored auth data.
    var stored = this.storage.get();

    // If nothing stored, proceed with new authorization
    if (!stored) {
      this.log('No auth data stored, starting authorization from scratch...');
      return this.auth.authorize();
    }

    // Otherwise, set the auth data on the Request object so that it can be used for requests
    this.log('Auth data stored, checking validity...');
    this._auth = utils.unserialize(stored);

    // Use the saved auth data to check if we're already authorized. If not, it will clear the stored
    // data, then proceed with new authorization.
    return this.auth.isAuth()
      .then(function(result) {
        if (result === false)
          return this.auth.authorize();
      }.bind(this));
  }
533038
def get_auth_bearer(self):
        """"""
        access_token = ''
        auth_header = self.get_header('authorization')
        if auth_header:
            m = re.search(r"^Bearer\s+(\S+)$", auth_header, re.I)
            if m: access_token = m.group(1)

        return access_token
388282
def auth(self):
        """"""
        response = requests.post(
            parse.urljoin(self.base_url, '/api/auth'),
            timeout=self.timeout,
            data={'username': self.username, 'password': self.password})
        response.raise_for_status()
        json = response.json()
        if 'jwt' not in json:
            raise ValueError("Not authorized: didn't receive token, check username or password.")
        self.jwt = json['jwt']
        return json
378790
def do_get(endpoint, access_token):
    '''
    '''
    headers = {"Authorization": 'Bearer ' + access_token}
    headers['User-Agent'] = get_user_agent()
    return requests.get(endpoint, headers=headers).json()