Download the PHP package audunru/social-accounts without Composer

On this page you can find all versions of the php package audunru/social-accounts. 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 social-accounts

Social Accounts for Laravel

Build Status Coverage Status StyleCI

Add social login (Google, Facebook, and others) to your Laravel app.

This package uses Laravel Socialite to authenticate users, and takes care of storing the provider (eg. Google) and provider user ID (eg. 123456789) as a SocialAccount (a related model of the User model).

Your users can add one or more social logins to their account. It's up to you if you want them to sign up with a normal username and password first, or if they can sign up just by signing in with a provider.

The package also has a JSON API so you can display which social accounts a user has logged in with, and allow them to remove them.

Installation

Step 1: Install with Composer

Step 2: Make changes to your code

First, you must add the HasSocialAccounts trait to your User model:

Second, you need to specify which providers you are going to support. Publish the configuration, and open up config/social-accounts.php and add them to the array.

There is an array called "providers" where you can specify the ones you want:

Third, you need to add credentials for your supported social login providers to config/services.php. To login with Google, you would add the following to config/services.php:

Fourth, you should call the SocialAccounts::routes method within the boot method of your AuthServiceProvider. This method will register the routes necessary to login with your configured providers. It will also register the API routes necessary for a user to retrieve their social accounts and remove them.

Optional: You can add web and API routes in separate steps.

Step 3: Configuration and customization

You can find the configuration and documentation of all options in config/social-accounts.php.

Step 4: Run migrations

The migrations will create a social_accounts table, which will hold all added social accounts.

If you set the "automatically_create_users" option in config/social-accounts.php to true, the email and password columns in your users table will be made nullable. Not all providers require users to have an email address, and the password column must be nullable because users who sign up this way won't have password.

Usage

Adding social login to existing users

If you want to allow your existing users to log in with Google, add a link to /social-accounts/login/google somewhere in your application:

After clicking on this link, the user will be redirected to Google, where they must authorize the request. Afterwards they will be returned to your app. Then, a new SocialAccount will be added as related model of the User.

Signing up users

If you want to allow users to sign up with this package, you must first publish the configuration file and then set automatically_create_users to true.

Then, run the migrations so that the email and password columns are made nullable.

Then add a link to /social-accounts/login/google:

Logging in

For users who are not signed in, simply add a link to /social-accounts/login/google:

Remember Me

Add "remember" to the login URL to keep the user signed in:

API

The JSON API, which by default is accessible at /social-accounts, allows authenticated users to retrieve their social accounts and remove them.

To retrieve an array of social accounts, make a GET request to /social-accounts.

To retrieve a single social account, make a GET request to /social-accounts/123, where 123 is the ID of the account.

To delete a social account, make a DELETE request to /social-accounts/123.

Users can't update social accounts through the API, they will have to delete them first and then authorize again.

Optional Parameters, Access Scopes and Stateless Authentication

To include optional parameters in the request, call the registerProviderSettings method on the facade. The method takes three parameters, the provider name, the name of the method to call on the provider object, and an array of parameters.

For example, you can use this to limit the domains a Google user can choose to sign in with to just one:

See Socialite's documentation for more info on Optional Parameters, Access Scopes and Stateless Authentication

Gates

You can use gates to allow or deny certain actions. Gates should be defined within the boot method of your AuthServiceProvider.

Events

When a user is created after authenticating with a provider, a SocialUserCreated event is dispatched. The event receives the User, SocialAccount and ProviderUser model.

When a social account is added to an existing user, a SocialAccountAdded event is dispatched. The event receives the User, SocialAccount and ProviderUser model.

For instance, you could listen for an event and grab more details about the user.

Alternatives

laravel-social-auth

Easy Socialite

Development

Testing

Run tests:


All versions of social-accounts with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^11.0
laravel/socialite Version ^5.0
spatie/laravel-package-tools Version ^1.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 audunru/social-accounts contains the following files

Loading the files please wait ....