Use an authoriztion code to connect an account to your platform and
fetch the user's credentials.

@param array|null $params
@param array|null $opts

@return StripeObject Object containing the response from the API.
973562
public static function token($params = null, $opts = null)
    {
        $base = ($opts && array_key_exists('connect_base', $opts)) ? $opts['connect_base'] : Stripe::$connectBase;
        $requestor = new ApiRequestor(null, $base);
        list($response, $apiKey) = $requestor->request(
            'post',
            '/oauth/token',
            $params,
            null
        );
        return Util\Util::convertToStripeObject($response->json, $opts);
    }
1040879
public function createAccountTicket(Google_Service_Analytics_AccountTicket $postBody, $optParams = array())
  {
    $params = array('postBody' => $postBody);
    $params = array_merge($params, $optParams);
    return $this->call('createAccountTicket', array($params), "Google_Service_Analytics_AccountTicket");
  }
197728
public function getUsers($opts = [])
    {
        $query = '';
        
        if(isset($opts['search'])) $query .= '?search='.$opts['search'];
        
    	$endpoint = '/users'.$query;        
    	return $this->doRequest('GET', $endpoint);
    }
959278
public static function authorizeUrl($params = null)
    {
        if (!$params) {
            $params = array();
        }

        $params['client_id'] = self::_getConnectParam('client_id', $params);
        $params['redirect_uri'] = self::_getConnectParam('redirect_uri', $params);
        if (!array_key_exists('response_type', $params)) {
            $params['response_type'] = 'code';
        }
        $query = Util\Util::urlEncode($params);

        return Sumup::$connectBase . '/authorize?' . $query;
    }
549156
protected static function all($params, $opts)
    {
        $url = self::classUrl();
        list($resp, $usedOpts) = self::request(self::METHOD_GET, $url, $params, $opts);
        $resp = Util\Util::arrayToObject($resp, $usedOpts);
        // Check the class name of the result because all feature must get the instance of Collection class.
        if (!is_a($resp, 'RpayLite\\Collection')) {
            $class = get_class($resp);
            $msg =  "'RpayLite\\Collection' is expected but '$class' is returned.";
            throw new Error\Api($msg);
        }
        return $resp;
    }
102796
public function buildAuthUrl(OAuthToken $requestToken = null, array $params = [])
    {
        if (!is_object($requestToken)) {
            $requestToken = $this->getState('requestToken');
            if (!is_object($requestToken)) {
                throw new InvalidParamException('Request token is required to build authorize URL!');
            }
        }
        $params['oauth_token'] = $requestToken->getToken();

        return $this->composeUrl($this->authUrl, $params);
    }
61298
protected function createPreOneTwentySeven( $params ) {
		$newParams = [
			'name' => $params['username'],
			'password' => $params['password'],
		];
		if ( array_key_exists( 'email', $params ) ) {
			$newParams['email'] = $params['email'];
		}
		// First get the token.
		$tokenRequest = new SimpleRequest( 'createaccount', $newParams );
		$result = $this->api->postRequest( $tokenRequest );
		if ( $result['createaccount']['result'] == 'NeedToken' ) {
			// Then send the token to create the account.
			$newParams['token'] = $result['createaccount']['token'];
			$request = new SimpleRequest( 'createaccount', $newParams );
			$result = $this->api->postRequest( $request );
		}
		return ( $result['createaccount']['result'] === 'Success' );
	}
1313651
public function getAccessTokenByRefreshToken(array $params = array())
    {
        $params = array(
            'grant_type' => 'refresh_token',
			'client_id' => $this->getClientId(),
            'client_secret' => $this->getClientSecret(),
		) + $params;
        if (empty($params['refresh_token'])) {
            $accessToken = $this->getAccessToken();
            if (empty($accessToken['refresh_token'])) {
                throw new InvalidArgumentException('Not configuration refresh_token');
            }
            $params['refresh_token'] = $accessToken['refresh_token'];
        }

        if (!empty($params['scope']) && is_array($params['scope'])) {
            $params['scope'] = implode(',', $params['scope']);
        }
        $request = $this->request('GET', 'oauth/2.0/token', $params);
        $this->accessToken = $request->response()->getJson(true);
        return $this->accessToken;
    }
1081669
private function authenticate($opt) {
		//set common param into opt
		$opt [self::AK] = $this->ak;
		$opt [self::SK] = $this->sk;

		// Validate the S3 bucket name, only list_bucket didnot need validate_bucket
		if (! ('/' == $opt [self::OBJECT] && '' == $opt [self::BUCKET] && 'GET' == $opt [self::METHOD] && ! isset ( $opt [self::QUERY_STRING] [self::ACL] )) && ! self::validate_bucket ( $opt [self::BUCKET] )) {
			throw new BCS_Exception ( $opt [self::BUCKET] . 'is not valid, please check!' );
		}
		//Validate object
		if (isset ( $opt [self::OBJECT] ) && ! self::validate_object ( $opt [self::OBJECT] )) {
			throw new BCS_Exception ( "Invalid object param[" . $opt [self::OBJECT] . "], please check.", - 1 );
		}
		//construct url
		$url = $this->format_url ( $opt );
		if ($url === false) {
			throw new BCS_Exception ( 'Can not format url, please check your param!', - 1 );
		}
		$opt ['url'] = $url;
		$this->log ( "[method:" . $opt [self::METHOD] . "][url:$url]", $opt );
		//build request
		$request = new BCS_RequestCore ( $opt ['url'] );
		$headers = array (
				'Content-Type' => 'application/x-www-form-urlencoded' );

		$request->set_method ( $opt [self::METHOD] );
		//Write get_object content to fileWriteTo
		if (isset ( $opt ['fileWriteTo'] )) {
			$request->set_write_file ( $opt ['fileWriteTo'] );
		}
		// Merge the HTTP headers
		if (isset ( $opt [self::HEADERS] )) {
			$headers = array_merge ( $headers, $opt [self::HEADERS] );
		}
		// Set content to Http-Body
		if (isset ( $opt ['content'] )) {
			$request->set_body ( $opt ['content'] );
		}
		// Upload file
		if (isset ( $opt ['fileUpload'] )) {
			if (! file_exists ( $opt ['fileUpload'] )) {
				throw new BCS_Exception ( 'File[' . $opt ['fileUpload'] . '] not found!', - 1 );
			}
			$request->set_read_file ( $opt ['fileUpload'] );
			// Determine the length to read from the file
			$length = $request->read_stream_size; // The file size by default
			$file_size = $length;
			if (isset ( $opt ["length"] )) {
				if ($opt ["length"] > $file_size) {
					throw new BCS_Exception ( "Input opt[length] invalid! It can not bigger than file-size", - 1 );
				}
				$length = $opt ['length'];
			}
			if (isset ( $opt ['seekTo'] ) && ! isset ( $opt ["length"] )) {
				// Read from seekTo until EOF by default, when set seekTo but not set $opt["length"]
				$length -= ( integer ) $opt ['seekTo'];
			}
			$request->set_read_stream_size ( $length );
			// Attempt to guess the correct mime-type
			if ($headers ['Content-Type'] === 'application/x-www-form-urlencoded') {
				$extension = explode ( '.', $opt ['fileUpload'] );
				$extension = array_pop ( $extension );
				$mime_type = BCS_MimeTypes::get_mimetype ( $extension );
				$headers ['Content-Type'] = $mime_type;
			}
			$headers ['Content-MD5'] = '';
		}
		// Handle streaming file offsets
		if (isset ( $opt ['seekTo'] )) {
			// Pass the seek position to BCS_RequestCore
			$request->set_seek_position ( ( integer ) $opt ['seekTo'] );
		}
		// Add headers to request and compute the string to sign
		foreach ( $headers as $header_key => $header_value ) {
			// Strip linebreaks from header values as they're illegal and can allow for security issues
			$header_value = str_replace ( array (
					"\r",
					"\n" ), '', $header_value );
			// Add the header if it has a value
			if ($header_value !== '') {
				$request->add_header ( $header_key, $header_value );
			}
		}
		// Set the curl options.
		if (isset ( $opt ['curlopts'] ) && count ( $opt ['curlopts'] )) {
			$request->set_curlopts ( $opt ['curlopts'] );
		}
		$request->send_request ();
		require_once(dirname(__FILE__). "/requestcore.class.php");
		return new BCS_ResponseCore ( $request->get_response_header (), $request->get_response_body (), $request->get_response_code () );
	}
951818
public function read(array $opts) {
        $instructor = parent::read($opts)['actor'];
        $statement =  array_merge_recursive(parent::read($opts), [
            'verb' => [
                'id' => 'http://adlnet.gov/expapi/verbs/scored',
                'display' => $this->readVerbDisplay($opts),
            ],
            'result' => [
                'score' => [
                    'raw' => $opts['grade_score_raw'],
                    'min' => $opts['grade_score_min'],
                    'max' => $opts['grade_score_max'],
                    'scaled' => $opts['grade_score_scaled']
                ],
                'completion' => $opts['grade_completed'],
                'response' => $opts['grade_comment']
            ],
            'object' => $this->readModule($opts),
            'context' => [
                'contextActivities' => [
                    'parent' => [
                        $this->readCourse($opts),
                    ],
                ],
                'instructor' => $instructor
            ],
        ]);

        //Excluded from array merge to make sure that the actor is overwritten e.g. if a different IFI is used. 
        $statement['actor'] = [
            'objectType' => 'Agent',
            'name' => $opts['graded_user_name'],
            'account' => [
                'homePage' => $opts['graded_user_url'],
                'name' => $opts['graded_user_id'],
            ],
        ];

        if (!is_null($opts['grade_success'])) {
            $statement['result']['success'] = $opts['grade_success'];
        }

        return $statement;
    }
1334027
public static function convertToStripeObject($resp, $opts)
    {
        $types = [
            // data structures
            \Stripe\Collection::OBJECT_NAME => 'Stripe\\Collection',

            // business objects
            \Stripe\Account::OBJECT_NAME => 'Stripe\\Account',
            \Stripe\AccountLink::OBJECT_NAME => 'Stripe\\AccountLink',
            \Stripe\AlipayAccount::OBJECT_NAME => 'Stripe\\AlipayAccount',
            \Stripe\ApplePayDomain::OBJECT_NAME => 'Stripe\\ApplePayDomain',
            \Stripe\ApplicationFee::OBJECT_NAME => 'Stripe\\ApplicationFee',
            \Stripe\Balance::OBJECT_NAME => 'Stripe\\Balance',
            \Stripe\BalanceTransaction::OBJECT_NAME => 'Stripe\\BalanceTransaction',
            \Stripe\BankAccount::OBJECT_NAME => 'Stripe\\BankAccount',
            \Stripe\BitcoinReceiver::OBJECT_NAME => 'Stripe\\BitcoinReceiver',
            \Stripe\BitcoinTransaction::OBJECT_NAME => 'Stripe\\BitcoinTransaction',
            \Stripe\Card::OBJECT_NAME => 'Stripe\\Card',
            \Stripe\Charge::OBJECT_NAME => 'Stripe\\Charge',
            \Stripe\Checkout\Session::OBJECT_NAME => 'Stripe\\Checkout\\Session',
            \Stripe\CountrySpec::OBJECT_NAME => 'Stripe\\CountrySpec',
            \Stripe\Coupon::OBJECT_NAME => 'Stripe\\Coupon',
            \Stripe\CreditNote::OBJECT_NAME => 'Stripe\\CreditNote',
            \Stripe\Customer::OBJECT_NAME => 'Stripe\\Customer',
            \Stripe\Discount::OBJECT_NAME => 'Stripe\\Discount',
            \Stripe\Dispute::OBJECT_NAME => 'Stripe\\Dispute',
            \Stripe\EphemeralKey::OBJECT_NAME => 'Stripe\\EphemeralKey',
            \Stripe\Event::OBJECT_NAME => 'Stripe\\Event',
            \Stripe\ExchangeRate::OBJECT_NAME => 'Stripe\\ExchangeRate',
            \Stripe\ApplicationFeeRefund::OBJECT_NAME => 'Stripe\\ApplicationFeeRefund',
            \Stripe\File::OBJECT_NAME => 'Stripe\\File',
            \Stripe\File::OBJECT_NAME_ALT => 'Stripe\\File',
            \Stripe\FileLink::OBJECT_NAME => 'Stripe\\FileLink',
            \Stripe\Invoice::OBJECT_NAME => 'Stripe\\Invoice',
            \Stripe\InvoiceItem::OBJECT_NAME => 'Stripe\\InvoiceItem',
            \Stripe\InvoiceLineItem::OBJECT_NAME => 'Stripe\\InvoiceLineItem',
            \Stripe\IssuerFraudRecord::OBJECT_NAME => 'Stripe\\IssuerFraudRecord',
            \Stripe\Issuing\Authorization::OBJECT_NAME => 'Stripe\\Issuing\\Authorization',
            \Stripe\Issuing\Card::OBJECT_NAME => 'Stripe\\Issuing\\Card',
            \Stripe\Issuing\CardDetails::OBJECT_NAME => 'Stripe\\Issuing\\CardDetails',
            \Stripe\Issuing\Cardholder::OBJECT_NAME => 'Stripe\\Issuing\\Cardholder',
            \Stripe\Issuing\Dispute::OBJECT_NAME => 'Stripe\\Issuing\\Dispute',
            \Stripe\Issuing\Transaction::OBJECT_NAME => 'Stripe\\Issuing\\Transaction',
            \Stripe\LoginLink::OBJECT_NAME => 'Stripe\\LoginLink',
            \Stripe\Order::OBJECT_NAME => 'Stripe\\Order',
            \Stripe\OrderItem::OBJECT_NAME => 'Stripe\\OrderItem',
            \Stripe\OrderReturn::OBJECT_NAME => 'Stripe\\OrderReturn',
            \Stripe\PaymentIntent::OBJECT_NAME => 'Stripe\\PaymentIntent',
            \Stripe\PaymentMethod::OBJECT_NAME => 'Stripe\\PaymentMethod',
            \Stripe\Payout::OBJECT_NAME => 'Stripe\\Payout',
            \Stripe\Person::OBJECT_NAME => 'Stripe\\Person',
            \Stripe\Plan::OBJECT_NAME => 'Stripe\\Plan',
            \Stripe\Product::OBJECT_NAME => 'Stripe\\Product',
            \Stripe\Radar\ValueList::OBJECT_NAME => 'Stripe\\Radar\\ValueList',
            \Stripe\Radar\ValueListItem::OBJECT_NAME => 'Stripe\\Radar\\ValueListItem',
            \Stripe\Recipient::OBJECT_NAME => 'Stripe\\Recipient',
            \Stripe\RecipientTransfer::OBJECT_NAME => 'Stripe\\RecipientTransfer',
            \Stripe\Refund::OBJECT_NAME => 'Stripe\\Refund',
            \Stripe\Reporting\ReportRun::OBJECT_NAME => 'Stripe\\Reporting\\ReportRun',
            \Stripe\Reporting\ReportType::OBJECT_NAME => 'Stripe\\Reporting\\ReportType',
            \Stripe\Review::OBJECT_NAME => 'Stripe\\Review',
            \Stripe\SKU::OBJECT_NAME => 'Stripe\\SKU',
            \Stripe\Sigma\ScheduledQueryRun::OBJECT_NAME => 'Stripe\\Sigma\\ScheduledQueryRun',
            \Stripe\Source::OBJECT_NAME => 'Stripe\\Source',
            \Stripe\SourceTransaction::OBJECT_NAME => 'Stripe\\SourceTransaction',
            \Stripe\Subscription::OBJECT_NAME => 'Stripe\\Subscription',
            \Stripe\SubscriptionItem::OBJECT_NAME => 'Stripe\\SubscriptionItem',
            \Stripe\SubscriptionSchedule::OBJECT_NAME => 'Stripe\\SubscriptionSchedule',
            \Stripe\SubscriptionScheduleRevision::OBJECT_NAME => 'Stripe\\SubscriptionScheduleRevision',
            \Stripe\TaxId::OBJECT_NAME => 'Stripe\\TaxId',
            \Stripe\TaxRate::OBJECT_NAME => 'Stripe\\TaxRate',
            \Stripe\ThreeDSecure::OBJECT_NAME => 'Stripe\\ThreeDSecure',
            \Stripe\Terminal\ConnectionToken::OBJECT_NAME => 'Stripe\\Terminal\\ConnectionToken',
            \Stripe\Terminal\Location::OBJECT_NAME => 'Stripe\\Terminal\\Location',
            \Stripe\Terminal\Reader::OBJECT_NAME => 'Stripe\\Terminal\\Reader',
            \Stripe\Token::OBJECT_NAME => 'Stripe\\Token',
            \Stripe\Topup::OBJECT_NAME => 'Stripe\\Topup',
            \Stripe\Transfer::OBJECT_NAME => 'Stripe\\Transfer',
            \Stripe\TransferReversal::OBJECT_NAME => 'Stripe\\TransferReversal',
            \Stripe\UsageRecord::OBJECT_NAME => 'Stripe\\UsageRecord',
            \Stripe\UsageRecordSummary::OBJECT_NAME => 'Stripe\\UsageRecordSummary',
            \Stripe\WebhookEndpoint::OBJECT_NAME => 'Stripe\\WebhookEndpoint',
        ];
        if (self::isList($resp)) {
            $mapped = [];
            foreach ($resp as $i) {
                array_push($mapped, self::convertToStripeObject($i, $opts));
            }
            return $mapped;
        } elseif (is_array($resp)) {
            if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) {
                $class = $types[$resp['object']];
            } else {
                $class = 'Stripe\\StripeObject';
            }
            return $class::constructFrom($resp, $opts);
        } else {
            return $resp;
        }
    }
327509
protected function getAccessTokenOptions(array $params)
    {
        $options = parent::getAccessTokenOptions($params);
        $options['headers']['Authorization'] =
            'Basic '.base64_encode($this->clientId.':'.$this->clientSecret);

        return $options;
    }
1251425
public function get($clientAccountId, $sponsorAccountId, $optParams = array())
  {
    $params = array('clientAccountId' => $clientAccountId, 'sponsorAccountId' => $sponsorAccountId);
    $params = array_merge($params, $optParams);
    return $this->call('get', array($params), "AdExchangeBuyer_ClientAccessCapabilities");
  }
1060019
public static function createExternalAccount($id, $params = null, $opts = null)
    {
        return self::_createNestedResource($id, static::PATH_EXTERNAL_ACCOUNTS, $params, $opts);
    }
975268
public static function all($params = null, $opts = null)
    {
        self::_validateParams($params);
        $url = static::classUrl();

        list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
        $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
        if (!is_a($obj, 'Stripe\\Collection')) {
            $class = get_class($obj);
            $message = "Expected type \"Stripe\\Collection\", got \"$class\" instead";
            throw new \Stripe\Error\Api($message);
        }
        $obj->setLastResponse($response);
        $obj->setRequestParams($params);
        return $obj;
    }
452802
public function authinfo($optParams = array())
  {
    $params = array();
    $params = array_merge($params, $optParams);
    return $this->call('authinfo', array($params), "Google_Service_ShoppingContent_AccountsAuthInfoResponse");
  }
233481
public function view($params, $optParams = [])
    {
        if ($params instanceof SuperBackup) {
            $params = $params->id;
        }
        if(!isset($optParams['cloud'])){
            $optParams['cloud'] = [];
        }
        $optParams['cloud']['id'] = $params;
        return $this->sendRequest([], [
            'restAction' => 'view',
            'uri' => '/c/<cloud.id>',
            'getParams' => $optParams,
        ], function ($response) {
            return isset($response->data) ? new SuperBackup($response->data) : $response;
        });
    }