Download the PHP package maer/oauth2-simple-client without Composer

On this page you can find all versions of the php package maer/oauth2-simple-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-simple-client

Oauth2 Simple Client

Build Status

Wrapper for league/oauth2-client with a simplified API and possibility to black/whitelist e-mail addresses/domains.

It is framework agnostic so you can just plug and play.

Install

You need composer to make this work, since this package is dependent on league/oauth2-client. I guess you could install that by hand as well, but since that package is dependent on other packages, you're setting yourself up for failure. ;-)

Add the package:

composer require maer/oauth2-simple-client 0.1.*

Make sure to include the composer-generated autoloader:

">Log in</a>

On the callback page example.com/callback/:

$user = $provider->authorize();

If the user was successfully autorized, you will get a user object back, otherwise it will return "false". Then you can check why by looking at the error message:

# For a human readable message
$errorMessage = $provider->getError();

# For an error code (check the constants in `Maer\Oauth2Simple\Client\Client`)
$errorCode = $provider->getErrorCode();

If you need the token:

$token = $provider->getToken();

If you want to do something that league/oauth2-client supports but isn't added to this wrapper, you can get the original provider:

$leaguesProvider = $provider->getProvider();

The manual way

$provider = new Maer\Oauth2Simple\Client\Client([
    'clientId'       => 'XXXXXXXX',
    'clientSecret'   => 'XXXXXXXX',
    'redirectUri'    => 'https://example.com/callback/',
    'scopes'         => ['email'],
    'provider'       => 'google',
    'emailAllow'     => ['[email protected]', '@example.com'], # Optional
    'emailDeny'      => ['[email protected]', '@evil.com'] # Optional
]);

Now it's up to you to save the $provider instance. Otherwise it's just like above.

E-mail allow/deny config

Maby we should talk about the allow- and deny lists. It is basically the reason I made this wrapper. :) With this you can decide who is or isn't allowed to authenticate/use your app depending on their e-mail address. This does require the e-mail to be returned from the provider so make sure you add the "email" in the scope. I will add the possibility to use oauthId's and other paramaeters, but started with e-mail since that was what I needed when I built this.

The emailAllow and emailDeny:

'emailAllow'     => ['[email protected]', '@example.com']

This will only allow the user with the e-mail address [email protected] or any user having an e-mail address on the @example.com domain. If this array is empty, or not provided at all, it will be counted as everyone is allowed.

'emailDeny'      => ['[email protected]', '@evil.com']

This will deny the user with the e-mail [email protected] even if the domain @example.com is allowed. No user from @evil.com is allowed at all. This is kind of a bad example, since @evil.com would have been denied anyway, since we have an allow-list. Denying a domain only makes sence if you don't have an allow list (which as I stated previously is regarded as everyone is allowed).


All versions of oauth2-simple-client with dependencies

PHP Build Version
Package Version
Requires league/oauth2-client Version 0.9.*
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 maer/oauth2-simple-client contains the following files

Loading the files please wait ....