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

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

Easily add OAuth2 access to your projects

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This OAuth for Laravel package provides a simple and reusable integration for implementing OAuth authentication in Laravel projects. The main goal is to allow developers to extend and customize their application's authentication system without needing to modify their existing user models.

The package is designed to work flexibly with any user model that implements the Authenticatable interface, ensuring that it can be easily adapted to various projects without direct dependencies on a specific user model.

Get to know us

Installation

You can install the package via composer:

The next step is to configure the package using this command:

When this command is executed, the user will be guided through a series of steps to properly configure the necessary variables in both the configuration file and the environment file.

Steps in the installation process:

Setting variables in the configuration file

Creation of variables in the .env file

IMPORTANT

If the process is not completed correctly or is aborted, the implementation and use of the package will result in errors, such as:

- Missing the new database table required to store OAuth user data.
- Incorrectly configured configuration file.
- Environment variables that are improperly defined or missing.

Once all steps are completed, the migrations will be automatically executed and the configuration file will be published.

You can publish different files:

Migrations

Config file

Translations

Implementing the Package in the Project

Before starting to develop the workflow, it is recommended to understand how the package works when creating or modifying users and groups.

To achieve this, two interfaces have been created: OAuthGroupHandlerInterface. These interfaces can be implemented in the user model of your application, allowing you to override the handleUser() and handleGroup() methods, respectively.

There are also two predefined classes: BaseOAuthGroupHandler, which implement these interfaces with default logic. These will serve as an example for the developer and will also help, if it is a simple application, for the package to work without having to overwrite anything.

IMPORTANT

It is likely necessary to implement these interfaces to override the logic for handling the users and groups returned by the OAuth service.

However, do not forget to override the user_handler and group_handler variables in the configuration file, specifying which model will override the interface methods.


Once you have installed the package in your project, the next step is to configure your own login flow. This can be done through a button, link, or any other interface element that triggers a function in a controller. In this function, you'll implement the package and call the request() function:

1. Create a Controller to Handle OAuth Authentication

First, you'll need to create a controller that handles the OAuth authentication logic. You can use the OAuthController provided by the package or create your own controller. The main goal is to call the request() method from the package to start the OAuth authentication process.

Example Controller:

2. Set Up a Login Route

In your routes file (routes/web.php), define a route that points to the controller you just created. This route will trigger the OAuth authentication process when the user interacts with the login button or link.

3. Create a Login Button or Link in the View

In your application's view (e.g., resources/views/auth/login.blade.php), add a button or link that points to the route you defined in the previous step. When the user clicks the button, the OAuth authentication process will begin.

4. Authentication Process

When the user clicks the button or link, a request will be sent to the login() function of the AuthController. From there, the controller will call the request() method of the package's OAuthController, which handles the OAuth authentication flow by redirecting the user to the OAuth provider for authorization.

Once the user completes the authorization process, the OAuth provider will redirect back to your application, where you can handle the response and authenticate the user in your system.

This will complete the integration of the OAuth package into your project, allowing you to set up a login flow that triggers the OAuth authentication process with a button or link.

Other features

This section talks about certain functions of the package, which are good to know.

Renew tokens

For token renewal, simply set the 'offline_access' variable in the configuration file to true; the package will handle the rest.

A middleware is available that calls the renew() function of the OAuthController. This function checks whether the authenticated user has an OAuth token and if the expiration time has not passed. If the token has expired, it will determine if a refresh token is being handled. It will either generate a new token or reject and unauthenticate the user's session accordingly.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of simple-oauth2-client with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^10.0|^11.0
laravel/framework Version ^10.0|^11.0
laravel/prompts Version ^0.1.25
league/oauth2-client Version ^2.7
livewire/livewire Version ^3.5
spatie/laravel-package-tools Version ^1.16
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 raiolanetworks/simple-oauth2-client contains the following files

Loading the files please wait ....