Create a new Client

@param string|string[]|null $redirectUris Client allowed redirect direct url's
323305
public static function createNewClient(string $name, $redirectUris = null): Client
    {
        if (isset($redirectUris) && is_string($redirectUris)) {
            $redirectUris = explode(' ', $redirectUris);
        }

        if (isset($redirectUris) && is_array($redirectUris)) {
            foreach ($redirectUris as &$redirectUri) {
                $redirectUri = trim((string) $redirectUri);
            }
        }

        $client = new static();

        $client->id = (string) Uuid::uuid4();
        $client->name = $name;
        $client->redirectUris = $redirectUris ?? [];

        return $client;
    }
1325226
protected function codeAskResourceOwnerForApproval(
        array $parameters,
        ClientInterface $client,
        string $redirectUri = null,
        int $maxStateLength = null
    ): ResponseInterface {
        $state = $this->codeGetState($parameters);
        if ($maxStateLength !== null && strlen($state) > $maxStateLength) {
            throw new OAuthCodeRedirectException(
                OAuthCodeRedirectException::ERROR_INVALID_REQUEST,
                $redirectUri,
                $state
            );
        }

        if ($client->isCodeGrantEnabled() === false) {
            throw new OAuthCodeRedirectException(
                OAuthCodeRedirectException::ERROR_UNAUTHORIZED_CLIENT,
                $redirectUri,
                $state
            );
        }

        $scope = $this->codeGetScope($parameters);
        list ($isScopeValid, $scopeList, $isScopeModified) =
            $this->codeGetIntegration()->codeValidateScope($client, $scope);
        if ($isScopeValid === false) {
            throw new OAuthCodeRedirectException(
                OAuthCodeRedirectException::ERROR_INVALID_SCOPE,
                $redirectUri,
                $state
            );
        }

        $response = $this->codeGetIntegration()->codeCreateAskResourceOwnerForApprovalResponse(
            $client,
            $redirectUri,
            $isScopeModified,
            $scopeList,
            $state
        );

        return $response;
    }
140954
protected function forceRedirect($redirectTo = '')
    {
        if (empty($redirectTo))
        {
            $this->runDefaultBehavior();
        }

        Craft::$app->response->redirect($redirectTo, $this->settings->redirectStatusCode);
    }
962634
public function logout($redirectUrl)
    {
        if (!empty($this->options['revoke_token_url']) && $this->options['force_login'] === true) {
            $redirectUrl = $this->normalizeUrl(
                $this->options['revoke_token_url'],
                ['post_logout_redirect_uri' => $redirectUrl]
            );
        }

        return new RedirectResponse($redirectUrl);
    }
347114
public function createUri($uri, array $params = [])
    {
        if ($uri instanceof GuzzleUri) {
            if (!empty($params)) {
                $uri = $uri->withQuery(http_build_query($params));
            }

            return $uri;
        }

        // If URL template given, prepare URI
        if (preg_match_all('/{[\w]+}/i', $uri, $matches)) {
            foreach (array_unique($matches[0]) as $match) {
                $param = substr($match, 1, -1);

                if (isset($params[$param])) {
                    $uri = str_replace($match, $params[$param], $uri);
                    unset($params[$param]);
                }
            }
        }

        if (!empty($params)) {
            $uri .= '?' . http_build_query($params);
        }

        return new GuzzleUri($uri);
    }
826401
public static function create(string $baseUrl, array $headers = [], $timeout = 30, bool $allowRedirects = false): Client
    {
        return new Client([
            'base_uri' => $baseUrl,
            'headers'  => $headers,
            'timeout'  => $timeout,
            'allow_redirects' => $allowRedirects,
        ]);
    }
57790
public function create($uri = null, $baseuri = null)
    {
        if (empty($uri) && empty($baseuri)) {
            // Empty uri means baseurl
            return $this->baseUrl
                . (($this->urlType == self::URL_APPEND)
                    ? "/$this->scriptName"
                    : null);
        } elseif (empty($uri)) {
            // Empty uri means baseurl with appended $baseuri
            ;
        } elseif (substr($uri, 0, 7) == "http://"
            || substr($uri, 0, 8) == "https://"
            || substr($uri, 0, 2) == "//"
        ) {
            // Fully qualified, just leave as is.
            return $uri;
        } elseif ($uri[0] == "/") {
            // Absolute url, prepend with siteUrl
            //return rtrim($this->siteUrl . rtrim($uri, '/'), '/');
            return $this->siteUrl . $uri;
        } elseif ($uri[0] == "#"
            || $uri[0] == "?"
        ) {
            // Hashtag url to local page, or query part leave as is.
            return $uri;
        } elseif (substr($uri, 0, 7) == "mailto:"
            || substr(html_entity_decode($uri), 0, 7) == "mailto:") {
            // Leave mailto links as is
            // The odd fix is for markdown converting mailto: to UTF-8
            // Might be a better way to solve this...
            return $uri;
        }

        // Prepend uri with baseuri
        $uri = rtrim($uri, "/");
        if (!empty($baseuri)) {
            $uri = rtrim($baseuri, "/") . "/$uri";
        }

        // Remove the trailing index part of the url
        if (basename($uri) == "index") {
            $uri = dirname($uri);
        }

        if ($this->urlType == self::URL_CLEAN) {
            return rtrim($this->baseUrl . "/" . $uri, "/");
        } else {
            return rtrim($this->baseUrl . "/" . $this->scriptName . "/" . $uri, "/");
        }
    }
1331303
private function createWildcardRoute(Redirect $redirect)
    {
        $origin = $redirect->getOrigin();
        $target = $redirect->getTarget();
        $url = $this->context->getPathInfo();

        $origin = substr($origin, 0, -1);
        $target = substr($target, 0, -1);
        $pathInfo = str_replace($origin, $target, $url);

        $this->context->setPathInfo($pathInfo);

        return new Route(
            $url, array(
                    '_controller' => 'FrameworkBundle:Redirect:urlRedirect',
                    'path' => $url,
                    'permanent' => $redirect->isPermanent(),
                ));
    }
83044
public function codeCreateAskResourceOwnerForApprovalResponse(
        ClientInterface $client,
        string $redirectUri = null,
        bool $isScopeModified = false,
        array $scopeList = null,
        string $state = null,
        array $extraParameters = []
    ): ResponseInterface {
        $this->logDebug('Asking resource owner for scope approval (code grant).');
        return $this->getIntegration()->createAskResourceOwnerForApprovalResponse(
            ResponseTypes::AUTHORIZATION_CODE,
            $client,
            $redirectUri,
            $isScopeModified,
            $scopeList,
            $state,
            $extraParameters
        );
    }
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;
    }
850006
public static Response withRedirect(String redirectTo) {
        Objects.requireNonNull(redirectTo, Required.REDIRECT_TO.toString());

        return new Response(redirectTo);
    }
218220
public function redirect($redirectUrl = null)
    {
        $state = null;

        if (!is_null($redirectUrl)) {
            $this->redirectUrl = $redirectUrl;
        }

        if ($this->usesState()) {
            $state = $this->makeState();
        }

        return new RedirectResponse($this->getAuthUrl($state));
    }
723524
public function callbackAction($callbackUri) {
		try {
			$this->authenticationManager->authenticate();
		} catch (\TYPO3\Flow\Security\Exception\AuthenticationRequiredException $exception) {
			$authenticationException = $exception;
		}

		if ($this->authenticationManager->isAuthenticated()) {
			$storedRequest = $this->securityContext->getInterceptedRequest();
			if ($storedRequest !== NULL) {
				$this->securityContext->setInterceptedRequest(NULL);
				$this->redirectToRequest($storedRequest);
			} else {
				// TODO Do we have to check the URI?
				$this->redirectToUri($callbackUri);
			}
		} else {
			throw new \Flowpack\SingleSignOn\Client\Exception('Could not authenticate in callbackAction triggered by the SSO server.', 1366613161, (isset($authenticationException) ? $authenticationException : NULL));
		}
	}
473718
public function getHttpClient( $uri = null )
    {
        $client = clone $this->httpClient;

        if ( $uri )
        {
            $client->setUri( $uri );
        }

        return $client;
    }
901887
public static function create($uri)
    {
        if (($parse = parse_url($uri)) === false) {
            throw new \InvalidArgumentException('Unable to parse URI');
        }

        return new Uri(
            isset($parse[ 'scheme' ])
                ? $parse[ 'scheme' ]
                : '',
            isset($parse[ 'host' ])
                ? $parse[ 'host' ]
                : '',
            isset($parse[ 'path' ])
                ? $parse[ 'path' ]
                : '',
            isset($parse[ 'port' ])
                ? $parse[ 'port' ]
                : '',
            isset($parse[ 'query' ])
                ? $parse[ 'query' ]
                : '',
            isset($parse[ 'fragment' ])
                ? $parse[ 'fragment' ]
                : '',
            isset($parse[ 'user' ])
                ? $parse[ 'user' ]
                : '',
            isset($parse[ 'pass' ])
                ? $parse[ 'pass' ]
                : ''
        );
    }
1216239
public function redirectByUrl($defaultRedirect = null, $key = null) {
		$redirectUrl = $this->getRedirectUrl($defaultRedirect, $key);

		return $this->_controller->redirect($redirectUrl);
	}
1181294
public function authorize($redirect_uri, $scope = Client::SCOPE_READ) {
		header('Location: ' . $this->getAuthorizeUri($redirect_uri, $scope));
		exit;
	}