Download the PHP package venveo/craft-oauthclient without Composer

On this page you can find all versions of the php package venveo/craft-oauthclient. 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 craft-oauthclient

OAuth 2.0 Client plugin for Craft CMS 3

This plugin provides developers with an easy centralized approach to managing and storing OAuth 2.0 clients and tokens.

It exposes an easy to use API and frontend for authorizing tokens for internal business logic. What it does not do is act as an authentication provider for users to login to the CMS.

Features

Example Use Cases

Example Non-Use Cases

Requirements

This plugin should work on Craft CMS 3.1.34.3 or later

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

    cd /path/to/project
  2. Then tell Composer to load the plugin:

    composer require venveo/craft-oauthclient
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for OAuth 2.0 Client.

  4. Configure on Craft settings page

Providers

A provider in this context is an OAuth 2.0 server that is exposing an API via token authorization. Out of the box, this plugin ships with the following providers:

The plugin utilizes the widely used oauth2-client project by thephpleague in order to make adding providers as painless as possible. We add an additional layer to this abstraction in order to mix in requirements for Craft.

Creating a Provider

Assuming a League provider already exists for your service, you can easily create your own implementation. In your module or plugin, create a file for the provider and follow this outline:

And now you need only register it in your plugin or module's init function:

php <?php use venveo\oauthclient\services\Providers; use craft\events\RegisterComponentTypesEvent; use MyProvider; // [...] Event::on(Providers::class, Providers::EVENT_REGISTER_PROVIDER_TYPES, function (RegisterComponentTypesEvent $event) { $event->types[] = MyProvider:class });

Using the Twig variable to check if the current user is connected

Modifying the authentication flow conditionally

Example 1: Modifying the OAuth Provider Settings

In this example, we'll render the connector with a context and register an event to modify the authorization parameters before the connection URL is rendered.

Example 2: Modifying the OAuth flow based on context

If we wanted to adjust the return URL the user is brought to after authenticating, we have two approaches. The first is quite simple and uses standard Craft form redirects:

The 2nd case is more complicated, and that's when we don't have a form, but instead just a button to the app.getRedirectUrl()

Since it's not a POST request, we need to make use of context to modify the flow. We'll call our context "my-custom-context" and invoke the redirect URL with that context:

Now in our module or plugin, we can just register an event handler for the AuthorizeController controller:

Success! Now upon logging in, the user will be sent to Google.

Brought to you by Venveo


All versions of craft-oauthclient with dependencies

PHP Build Version
Package Version
Requires craftcms/cms Version ^3.1.34.3
league/oauth2-client Version ^2.2.1
league/oauth2-google Version ^2.2
league/oauth2-facebook Version ^2.0
league/oauth2-github Version ^2.0
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 venveo/craft-oauthclient contains the following files

Loading the files please wait ....