Download the PHP package spaces/oauth2-client without Composer

On this page you can find all versions of the php package spaces/oauth2-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package oauth2-client

SPACES OAuth2.0 authentication

Build Status Packagist

Client library to integrate an OAuth2.0 authorization flow into PHP applications.

Usage

  1. Provide your own implementation of the Mw\Spaces\OAuth2\Context interface:

    namespace Your\Namespace;
    
    class Context implements \Mw\Spaces\OAuth2\Context
    {
        public function getRedirectURI()
        {
            return "https://my-application.example/oauth-redir";
        }        
    }

    Note that the /oauth-redir path needs to point to an application-specific OAuth2 redirection handler implemented by you.

  2. Create the OAuth2.0 provider:

    $ctx = new \Your\Namespace\Context();
    $opts = new \Mw\Spaces\OAuth2\EnvironmentOptions($_SERVER);
    
    $provider = new \Mw\Spaces\OAuth2\SpacesProvider($opts, $ctx); 
  3. Next, retrieve the authorization URL and redirect your user there:

    $authorizationURL = $provider->getAuthorizationUrl();
    
    $_SESSION["spaces.de/auth/csrf"] = $provider->getState();
    
    header("Location: " . $authorizationURL);
  4. The identity provider will prompt the user for their credentials, and - on success - will redirect the user back to your Redirect URI. When handling the redirected request, you'll need to retrieve the authorization code and check the CSRF value:

    $state = $_GET["state"];
    $code  = $_GET["code"];
    
    if ($_SESSION["spaces.de/auth/csrf"] != $state) {
        die("...");
    }

    After that, you can use the code to retrieve your access token:

    $accessToken = $provider->getAccessToken('authorization_code', [
        'code' => $code,
    ]);
  5. Having the $accessToken, you can now (all while handling the redirected request) use that token to load the resource owner:

    try {
        $owner = $provider->getResourceOwner($accessToken);
        $ownerID = $accessToken->getResourceOwnerId();
    
        // synchronize local user using $owner
    } catch (\Mw\Spaces\OAuth2\Error\UserNotPresentException $err) {
        // user has no access to project
        // deny login
    }

    Use the data in the $owner object to construct a new local user (or update an existing record). You can store the Resource Owner ID for each created user to match them later on.


All versions of oauth2-client with dependencies

PHP Build Version
Package Version
Requires league/oauth2-client Version ^2.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package spaces/oauth2-client contains the following files

Loading the files please wait ...