Refreshes login token using refresh token

    Refreshes login token using refresh token # noqa: E501


    :rtype: UserAuth
762911
def refresh_token():  # noqa: E501
    
    current_user = get_jwt_identity()
    if not current_user:
        return ErrorResponse(status=401, message="Not logged in")
    access_token = create_access_token(identity=current_user)
    return AuthResponse(status=201, message='Refreshed Access Token', access_token=access_token, auth=UserAuth())
541784
def login(self):
        
        log.debug('Logging into RightScale...')
        login_data = {
            'grant_type': 'refresh_token',
            'refresh_token': self.refresh_token,
            }
        response = self._request('post', self.oauth_path, data=login_data)

        raw_token = response.json()
        auth_token = "Bearer %s" % raw_token['access_token']
        self.s.headers['Authorization'] = auth_token

        # Generate an expiration time for our token of 60-seconds before the
        # standard time returned by RightScale. This will be used in the
        # self.client property to validate that our token is still usable on
        # every API call.
        log.debug('Auth Token expires in %s(s)' % raw_token['expires_in'])
        self.auth_expires_at = time.time() + int(raw_token['expires_in']) - 60
187015
def _requires_refresh_token(self):
        
        expires_on = datetime.datetime.strptime(
            self.login_data['token']['expiresOn'], '%Y-%m-%dT%H:%M:%SZ')
        refresh = datetime.datetime.utcnow() + datetime.timedelta(seconds=30)
        return expires_on < refresh
446036
def set_session_token(self, session_token):
        
        self.session_token = session_token
        self._login_time = datetime.datetime.now()
1289541
def refresh(self):
        
        data = {
            'grant_type': 'refresh_token',
            'refresh_token': self._token.refresh_token
        }

        response = self.http_client.post(self.URL, data=data, auth=(self.client_id, self.client_secret))
        response.raise_for_status()
        self._token = Token.from_json(response.json())
1057337
def refresh_token(self, **kwargs):
        
        if 'client_secret' not in kwargs:
            kwargs.update(client_secret=self.client_secret)
        if 'client_id' not in kwargs:
            kwargs.update(client_id=self.client_id)
        return self.session.refresh_token(token_url, **kwargs)
876479
def refresh_authorizer_token(
            self, authorizer_appid, authorizer_refresh_token):
        
        return self.post(
            '/component/api_authorizer_token',
            data={
                'component_appid': self.component_appid,
                'authorizer_appid': authorizer_appid,
                'authorizer_refresh_token': authorizer_refresh_token
            }
        )
307967
def verify_http_auth_refresh_token(self) -> bool:
        
        authorization_token = self.get_http_token()
        if authorization_token is not None:
            if self.verify_refresh_token(authorization_token):
                if self.data is not None:
                    self.data = self.data['data']
                    return True
                return False
            else:
                return False
        return False
62979
private function refreshToken()
    {

        // Make the post request for a new access_token
        $response = $this->httpRequest('post',
            $this->sso_base . '/token/?grant_type=refresh_token&refresh_token=' .
            $this->authentication->refresh_token, [
                'Authorization' => 'Basic ' . base64_encode(
                        $this->authentication->client_id . ':' . $this->authentication->secret),
            ]
        );

        // Get the current EsiAuth container
        $authentication = $this->getAuthentication();

        // Set the new authentication values from the request
        $authentication->access_token = $response->access_token;
        $authentication->refresh_token = $response->refresh_token;
        $authentication->token_expires = carbon('now')
            ->addSeconds($response->expires_in);

        // ... and update the container
        $this->setAuthentication($authentication);
    }
295603
def login(self):
        
        form = self._get_form('SECURITY_LOGIN_FORM')
        if form.validate_on_submit():
            try:
                self.security_service.login_user(form.user, form.remember.data)
            except AuthenticationError as e:
                form._errors = {'_error': [str(e)]}
            else:
                self.after_this_request(self._commit)
                if request.is_json:
                    return self.jsonify({'token': form.user.get_auth_token(),
                                         'user': form.user})
                self.flash(_('flask_unchained.bundles.security:flash.login'),
                           category='success')
                return self.redirect('SECURITY_POST_LOGIN_REDIRECT_ENDPOINT')
        else:
            # FIXME-identity
            identity_attrs = app.config.SECURITY_USER_IDENTITY_ATTRIBUTES
            msg = f"Invalid {', '.join(identity_attrs)} and/or password."

            # we just want a single top-level form error
            form._errors = {'_error': [msg]}
            for field in form._fields.values():
                field.errors = None

        if form.errors and request.is_json:
            return self.jsonify({'error': form.errors.get('_error')[0]},
                                code=HTTPStatus.UNAUTHORIZED)

        return self.render('login',
                           login_user_form=form,
                           **self.security.run_ctx_processor('login'))
648108
def auth_token(cls, token):
        

        store = goldman.sess.store
        login = store.find(cls.RTYPE, 'token', token)

        if not login:
            msg = 'No login found with that token. It may have been revoked.'
            raise AuthRejected(**{'detail': msg})
        elif login.locked:
            msg = 'The login account is currently locked out.'
            raise AuthRejected(**{'detail': msg})
        else:
            login.post_authenticate()
793940
def Refresh(self, autoRelogin=False, dumpXml=YesOrNo.FALSE):
		
		self._Stop_refresh_timer()

		response = self.AaaRefresh(self._username, self._password, dumpXml)
		if (response.errorCode != 0):
			self._cookie = None
			if (autoRelogin):
				return self.Login(self._name, self._username, self._password, self._noSsl, self._port, dumpXml,
								  self._proxy, autoRefresh=YesOrNo.TRUE)
			return False

		self._domains = response.OutDomains
		self._priv = response.OutPriv.split(',')
		self._refreshPeriod = int(response.OutRefreshPeriod)
		self._cookie = response.OutCookie

		# re-enable the timer
		self._Start_refresh_timer()
		return True
125692
def refresh(self, using=None, **kwargs):
        
        return self._get_connection(using).indices.refresh(index=self._name, **kwargs)
1343826
def refresh(self, refresh_token):
        
        r = requests.post(self.apiurl + "/token", params={"grant_type": "refresh_token", "client_id": self.cid,
                                                          "client_secret": self.csecret,
                                                          "refresh_token": refresh_token})

        if r.status_code != 200:
            raise ServerError

        jsd = r.json()

        return jsd['access_token'], int(jsd['expires_in']) + int(jsd['created_at'])
97891
def update_token(self):
        
        if not self.username or not self.password:
            raise errors.TokenExpired("Unable to refresh token - no username or password.")
        encoded_uri = compat.quote_plus(self.uri).encode(self._encoding)  # pylint: disable=no-member
        encoded_key = compat.quote_plus(self.username).encode(self._encoding)  # pylint: disable=no-member
        self.expires_at = time.time() + self.expires_in.seconds
        self.token = utils.create_sas_token(
            encoded_key,
            self.password.encode(self._encoding),
            encoded_uri,
            self.expires_in)
301223
async def generate_refresh_token(self, request, user):
        
        refresh_token = await utils.call(self.config.generate_refresh_token())
        user_id = await self._get_user_id(user)
        await utils.call(
            self.store_refresh_token,
            user_id=user_id,
            refresh_token=refresh_token,
            request=request,
        )
        return refresh_token
41755
def login(self):
		
		if self.options['token']:
			self.client.token = self.options['token']
			result = self.users.get_user('me')
		else:
			response = self.users.login_user({
				'login_id': self.options['login_id'],
				'password': self.options['password'],
				'token': self.options['mfa_token']
			})
			if response.status_code == 200:
				self.client.token = response.headers['Token']
				self.client.cookies = response.cookies
			try:
				result = response.json()
			except ValueError:
				log.debug('Could not convert response to json, returning raw response')
				result = response

		log.debug(result)

		if 'id' in result:
			self.client.userid = result['id']
		if 'username' in result:
			self.client.username = result['username']

		return result