DoReauthorization

Used to reauthorize a previously-authorized order which has expired
977362
function DoReauthorization($txnID, $amount = 0, $currency = 'USD') {
    $values['AUTHORIZATIONID'] = $txnID;
    $values['AMT'] = number_format($amount, 2, '.', ',');
    $values['CURRENCYCODE'] = $currency;
    return $this->_request($values, 'DoReauthorization');
  }
573609
def _is_expired_response(self, response):
        
        if response.status_code != 401:
            return False
        challenge = response.headers.get('www-authenticate', '')
        return 'error="invalid_token"' in challenge
1332475
def clean_expired_tokens(opts):
    '''
    
    '''
    loadauth = salt.auth.LoadAuth(opts)
    for tok in loadauth.list_tokens():
        token_data = loadauth.get_tok(tok)
        if 'expire' not in token_data or token_data.get('expire', 0) < time.time():
            loadauth.rm_token(tok)
446951
private void handleAuthorizationSuccess(Response response) {

        Iterator<ResponseListener> iterator = authorizationQueue.iterator();

        while(iterator.hasNext()) {
            ResponseListener next = iterator.next();
            next.onSuccess(response);
            iterator.remove();
        }
    }
672053
protected function reauthorize()
    {
        $order = $this->getOrder();

        if ($order->getCapturedAmount() > 0) {
            $handler = $this->getReauthorizeHandler();
            try {
                $response = $handler->getPayPalResponse();

                $payment = oxNew(\OxidEsales\PayPalModule\Model\OrderPayment::class);
                $payment->setDate($this->getDate());
                $payment->setTransactionId($response->getAuthorizationId());
                $payment->setCorrelationId($response->getCorrelationId());
                $payment->setAction('re-authorization');
                $payment->setStatus($response->getPaymentStatus());

                $order->getPaymentList()->addPayment($payment);
            } catch (\OxidEsales\PayPalModule\Core\Exception\PayPalResponseException $e) {
                // Ignore PayPal response exceptions
            }
        }
    }
438316
private function _convertAuthorize($request) {
        
        $parameters = array();
        $parameters['Action'] = 'Authorize';
        if ($request->isSetSellerId()) {
            $parameters['SellerId'] =  $request->getSellerId();
        }
        if ($request->isSetAmazonOrderReferenceId()) {
            $parameters['AmazonOrderReferenceId'] =  $request->getAmazonOrderReferenceId();
        }
        if ($request->isSetAuthorizationReferenceId()) {
            $parameters['AuthorizationReferenceId'] =  $request->getAuthorizationReferenceId();
        }
        if ($request->isSetAuthorizationAmount()) {
            $authorizationAmount = $request->getAuthorizationAmount();
            if ($authorizationAmount->isSetAmount()) {
                $parameters['AuthorizationAmount' . '.' . 'Amount'] =  $authorizationAmount->getAmount();
            }
            if ($authorizationAmount->isSetCurrencyCode()) {
                $parameters['AuthorizationAmount' . '.' . 'CurrencyCode'] =  $authorizationAmount->getCurrencyCode();
            }
        }
        if ($request->isSetSellerAuthorizationNote()) {
            $parameters['SellerAuthorizationNote'] =  $request->getSellerAuthorizationNote();
        }
        if ($request->isSetOrderItemCategories()) {
            $orderItemCategories = $request->getOrderItemCategories();
            foreach  ($orderItemCategories->getOrderItemCategory() as $orderItemCategoryIndex => $orderItemCategory) {
                $parameters['OrderItemCategories' . '.' . 'OrderItemCategory' . '.'  . ($orderItemCategoryIndex + 1)] =  $orderItemCategory;
            }
        }
        if ($request->isSetTransactionTimeout()) {
            $parameters['TransactionTimeout'] =  $request->getTransactionTimeout();
        }
        if ($request->isSetCaptureNow()) {
            $parameters['CaptureNow'] =  $request->getCaptureNow() ? "true" : "false";
        }
        if ($request->isSetSoftDescriptor()) {
            $parameters['SoftDescriptor'] =  $request->getSoftDescriptor();
        }

        return $parameters;
    }
172386
public function revokeAllAuthority($authorization, $client_id) {
        $instance = new revokeAllAuthority($this, $this->getUserAgent(), $authorization, $client_id);
        return $instance;
    }
770345
private void removeFromPermissionsCache(IAuthorizationPrincipal[] principals)
            throws AuthorizationException {
        for (int i = 0; i < principals.length; i++) {
            cacheRemove(principals[i]);
        }
    }
719938
def refresh_authorization(self):
        
        response = self.request_handler.post(
            endpoint='oauth/token',
            omit_api_version=True,
            data={
                'grant_type': 'refresh_token',
                'client_id': self.auth.client_id,
                'client_secret': self.auth.client_secret,
                'refresh_token': self.auth.refresh_token,
            }
        )
        data = response.json()
        token_expiration = (datetime.datetime.utcnow() + datetime.timedelta(seconds=data['expires_in']))
        self.auth.update(
            token_expiration=token_expiration,
            access_token=data['access_token'],
            refresh_token=data['refresh_token'],
        )
        return {
            'access_token': self.auth.access_token,
            'refresh_token': self.auth.refresh_token,
            'token_expiration': format_event_time(self.auth.token_expiration),
        }
264932
def application_unauthenticated(request, token, state=None, label=None):
    
    application = base.get_application(secret_token=token)
    if application.expires < datetime.datetime.now():
        return render(
            template_name='kgapplications/common_expired.html',
            context={'application': application},
            request=request)

    roles = {'is_applicant', 'is_authorised'}

    # redirect user to real url if possible.
    if request.user.is_authenticated:
        if request.user == application.applicant:
            url = base.get_url(
                request, application, roles, label)
            return HttpResponseRedirect(url)

    state_machine = base.get_state_machine(application)
    return state_machine.process(
        request, application, state, label, roles)
769898
def renew_authorization(wait = nil)
      wait ||= (state == :authorized) ? ((@expires_at - Time.now).to_i / RENEW_FACTOR) : 0

      if @renew_timer && wait == 0
        @renew_timer.cancel
        @renew_timer = nil
      end

      unless @renew_timer
        @renew_timer = EM_S::Timer.new(wait) do
          @renew_timer = nil
          previous_state = state
          begin
            get_authorized
            renew_authorization
          rescue Exceptions::ConnectivityFailure => e
            if wait > 0
              renew_authorization([(wait * RENEW_FACTOR), MAX_RENEW_TIME].min)
            else
              renew_authorization(MIN_RENEW_TIME)
            end
          rescue BalancedHttpClient::NotResponding => e
            if (expires_in = (@expires_at - Time.now).to_i) > MIN_RENEW_TIME
              renew_authorization(expires_in / RENEW_FACTOR)
            else
              self.state = :expired
              reconnect
            end
          rescue Exceptions::Unauthorized => e
            if previous_state == :unauthorized && wait > 0
              renew_authorization([(wait * RENEW_FACTOR), MAX_UNAUTHORIZED_RENEW_INTERVAL].min)
            else
              renew_authorization(UNAUTHORIZED_RENEW_INTERVAL)
            end
          rescue CommunicationModeSwitch => e
            ErrorTracker.log(self, "Failed authorization renewal", e, nil, :no_trace)
            self.state = :failed
          rescue Exception => e
            ErrorTracker.log(self, "Failed authorization renewal", e)
            self.state = :failed
          end
        end
      end
      true
    end
43280
def downgrade():
    """"""
    # Remove 'created' and 'updated' columns
    op.drop_column('oauthclient_remoteaccount', 'created')
    op.drop_column('oauthclient_remoteaccount', 'updated')

    op.drop_column('oauthclient_remotetoken', 'created')
    op.drop_column('oauthclient_remotetoken', 'updated')

    op.drop_column('oauthclient_useridentity', 'created')
    op.drop_column('oauthclient_useridentity', 'updated')
1183127
public static DeauthorizedAccount deauthorize(Map<String, Object> params, RequestOptions options)
      throws StripeException {
    String url = Stripe.getConnectBase() + "/oauth/deauthorize";
    params.put("client_id", getClientId(params, options));
    return OAuth.stripeResponseGetter.oauthRequest(ApiResource.RequestMethod.POST, url, params,
        DeauthorizedAccount.class, ApiResource.RequestType.NORMAL, options);
  }
1249520
def exchange_code_for_token(self, authorization_code):
        # type: (str) -> se_leg_op.access_token.AccessToken
        
        if authorization_code not in self.authorization_codes:
            raise InvalidAuthorizationCode('{} unknown'.format(authorization_code))

        authz_info = self.authorization_codes[authorization_code]
        if authz_info['used']:
            logger.debug('detected already used authz_code=%s', authorization_code)
            raise InvalidAuthorizationCode('{} has already been used'.format(authorization_code))
        elif authz_info['exp'] < int(time.time()):
            logger.debug('detected expired authz_code=%s, now=%s > exp=%s ',
                         authorization_code, int(time.time()), authz_info['exp'])
            raise InvalidAuthorizationCode('{} has expired'.format(authorization_code))

        authz_info['used'] = True

        access_token = self._create_access_token(authz_info['sub'], authz_info[self.KEY_AUTHORIZATION_REQUEST],
                                                 authz_info['granted_scope'])

        logger.debug('authz_code=%s exchanged to access_token=%s', authorization_code, access_token.value)
        return access_token
846491
def no_auth(self):
        """"""
        old_basic_auth, self.auth = self.auth, None
        old_token_auth = self.headers.pop('Authorization', None)

        yield

        self.auth = old_basic_auth
        if old_token_auth:
            self.headers['Authorization'] = old_token_auth
667011
function revokePermission (commandOptions, { accountId, grantablePermissionName }) {
  return command(
    commandOptions,
    txHelper.addCommand(
      txHelper.emptyTransaction(),
      'revokePermission',
      {
        accountId,
        grantablePermissionName
      }
    )
  )
}
332039
def close_authorization(
      amazon_authorization_id,
      closure_reason: nil,
      merchant_id: @merchant_id,
      mws_auth_token: nil
    )

      parameters = {
        'Action' => 'CloseAuthorization',
        'SellerId' => merchant_id,
        'AmazonAuthorizationId' => amazon_authorization_id
      }

      optional = {
        'ClosureReason' => closure_reason,
        'MWSAuthToken' => mws_auth_token
      }

      operation(parameters, optional)
    end