Download the PHP package emmanuel-saleem/social-auth without Composer

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

Emmanuel Saleem Social Auth Package

A comprehensive Laravel package for OAuth social authentication with Google and Microsoft, supporting both traditional web applications and modern SPA/API-based frontends.

License: MIT Laravel PHP Version

๐Ÿ“š Table of Contents


โœจ Features


๐Ÿ“‹ Requirements


๐Ÿ“ฆ Installation

Step 1: Install via Composer

For Development (Current Available Version):

Alternative Installation Methods:

๐Ÿ“ Note: The package is currently in development. Stable versions will be available after publishing to Packagist. Use dev-master for now.

Step 2: Install Authentication System (for API routes)

Option A: Laravel Sanctum (Recommended - Default)

Option B: Laravel Passport (For OAuth2 Server)

๐Ÿ“– See PASSPORT_SETUP.md for detailed Passport configuration

Step 3: Add HasApiTokens to User Model

For Sanctum (Default):

For Passport:

Then configure the driver in .env:

Step 4: Publish Package Assets


โš™๏ธ Configuration

Environment Variables

Add these to your .env file:

Update config/services.php

Add OAuth provider configurations:

OAuth Provider Setup

Google Cloud Console

Follow these steps to create OAuth credentials:

Step 1: Go to Google Cloud Console

Step 2: Create a new project or select an existing one

Step 3: Navigate to "APIs & Services" โ†’ "Credentials"

Step 4: Click "CREATE CREDENTIALS" โ†’ Select "OAuth client ID"

Step 5: Configure the OAuth consent screen (if first time)

Step 6: Select "Web application" as the application type

Step 7: Add your application name and authorized redirect URIs:

Authorized redirect URIs:

Step 8: Click "CREATE" and you'll receive your credentials

Step 9: Copy the Client ID and Client Secret to your .env file

Step 10: Enable required APIs (Google+ API or People API)

โœ… Configuration Complete! Now add the credentials to your .env file:

Microsoft Azure Portal

Follow these detailed steps to set up Microsoft OAuth authentication:

Step 1: Access Azure Portal

  1. Go to Azure Portal
  2. Sign in with your Microsoft account

Step 2: Navigate to App Registrations

  1. In the Azure portal, search for "App registrations" in the search bar
  2. Click on "App registrations" from the search results

Step 3: Create New App Registration

  1. Click "New registration" button
  2. Fill in the application details:
    • Name: Enter your application name (e.g., "Laravel Social Auth")
    • Supported account types: Choose based on your needs:
      • "Personal Microsoft accounts only" - for consumer apps
      • "Accounts in any organizational directory and personal Microsoft accounts" - for broader access
    • Redirect URI: Add your callback URL:
      • Web: http://localhost:8000/emmanuel-saleem/social-auth/microsoft/callback
      • API: http://localhost:3000/auth/microsoft/callback

Step 4: Configure Authentication

  1. After creating the app, go to "Authentication" in the left menu
  2. Add your redirect URIs:
    • http://localhost:8000/emmanuel-saleem/social-auth/microsoft/callback
    • https://yourdomain.com/emmanuel-saleem/social-auth/microsoft/callback (for production)

Step 5: Create Client Secret

  1. Go to "Certificates & secrets" in the left menu
  2. Click "New client secret"
  3. Add a description and choose expiration period
  4. Important: Copy the secret value immediately (it won't be shown again)

Step 6: Configure API Permissions

  1. Go to "API permissions" in the left menu
  2. Click "Add a permission"
  3. Select "Microsoft Graph"
  4. Choose "Delegated permissions"
  5. Add these permissions:
    • openid
    • profile
    • email
    • User.Read
    • offline_access

Step 7: Grant Admin Consent

  1. Click "Grant admin consent" button
  2. Confirm the permissions

Step 8: Get Your Credentials

  1. Go to "Overview" in the left menu
  2. Copy the following values:
    • Application (client) ID
    • Directory (tenant) ID (if using specific tenant)

Step 9: Update Your .env File Add the Microsoft credentials to your .env file:

Important Notes:


๐Ÿš€ Quick Start - Add Login to Your App

How to Add Google & Microsoft Login

After installation, you have 3 easy ways to add social login to your application:

Method 1: Use the Pre-built Login Page (Easiest)

Simply redirect users to the package's built-in login page:

Visit: http://localhost:8000/emmanuel-saleem/social-auth/login

The page will show beautiful Google and Microsoft login buttons automatically! โœจ


Method 2: Include the Component in Your Own Page

Add the social auth buttons to any existing page:

That's it! Both Google and Microsoft buttons will appear with icons and proper styling.


Method 3: Create Your Own Custom Buttons

Use the package routes directly for full customization:


Logout Button

Add a logout button anywhere in your app:


๐ŸŽฏ What Happens After Login?

  1. User clicks "Sign in with Google" or "Sign in with Microsoft"
  2. Redirects to Google/Microsoft for authentication
  3. User approves the login request
  4. Redirects back to your app with user data
  5. Package automatically:
    • Creates a new user (if doesn't exist)
    • Updates existing user info
    • Logs them in
    • Redirects to dashboard (configurable)

User is now logged in! ๐ŸŽ‰

Access logged-in user anywhere:


๐ŸŒ Complete Web Integration Guide

Step-by-Step: Add Social Login to Your Laravel Web App

Step 1: Create Your Login Page

Create or update your login blade file at resources/views/auth/login.blade.php:

Step 2: Create a Route for Login Page

Add to routes/web.php:

Step 3: Update Your Welcome Page (Optional)

Add a login button to resources/views/welcome.blade.php:

Step 4: Create a Dashboard Page

Create resources/views/dashboard.blade.php:

Step 5: Add Dashboard Route

Add to routes/web.php:


๐Ÿงช Testing Your Social Login

Test 1: Visit Login Page

Expected Result:

Test 2: Click "Continue with Google"

What Happens:

  1. Redirects to Google login page
  2. Google asks for permission
  3. You approve
  4. Redirects back to your app
  5. Package creates/updates user
  6. Logs you in automatically
  7. Redirects to /dashboard (configurable)

Check Database:

Test 3: Check User Data in Dashboard

Visit: http://localhost:8000/dashboard

Expected Result:

Test 4: Test Logout

Click the "Logout" button

Expected Result:

Test 5: Test Microsoft Login

Follow same steps but click "Continue with Microsoft"

Expected Result:


๐Ÿ” Debugging & Verification

Check Routes Are Loaded

Expected Output:

Check Database Table

Should show the social auth migration as completed.

Should show columns:

Check Logged-in User

In any controller or view:


๐Ÿ“ธ Quick Test Checklist


๐ŸŽจ Customize Redirect After Login

In .env file:

Or in config/emmanuel-saleem-social-auth.php:


๐Ÿš€ Usage

Option 1: Traditional Web Application

Routes Available

The package automatically registers these web routes:

Implementation

Option A: Use the built-in login page

Simply redirect users to the login page:

Option B: Include the component in your own page

The package provides a reusable Blade component that you can include anywhere:

Option C: Use individual buttons

Logout



Option 2: API / SPA Application (React, Vue, Next.js)

For modern frontend applications, use the API endpoints.

Frontend Login Flow

Step 1: User clicks "Sign in with Google" button

Step 2: Get the OAuth URL from backend:

Step 3: Handle the callback when user returns:

Step 4: Use the token for authenticated requests:

For complete React/Vue examples, see USAGE_EXAMPLES.md

Next.js example pages

Add these pages to your Next.js app for a quick end-to-end test with this package's API endpoints.

app/(public)/auth/google/callback/page.tsx

app/(public)/oauth-test/page.tsx

API Routes Available

Quick Start Example (React)

๐Ÿ“– For complete API integration guide, see OAUTH_API_GUIDE.md


๐Ÿ“ก API Response Format

All API endpoints return standardized JSON responses:

Success Response

Error Response


๐ŸŽจ Customization

Customize Button Labels

You can customize the button text via .env file:

Or in the config file config/emmanuel-saleem-social-auth.php:

Customize Footer

Hide the footer:

Or customize the footer text:

In config file:

Customize Routes Prefix

Edit config/emmanuel-saleem-social-auth.php:

Customize Redirects

Customize Middleware

Customize Views

After publishing views:

Edit the views in resources/views/vendor/emmanuel-saleem-social-auth/

The component includes:


๐Ÿ—„๏ธ Database Schema

The package adds these fields to your users table:

Column Type Description
google_id string Google user ID
microsoft_id string Microsoft user ID
avatar string Profile picture URL
google_token text Google access token
google_refresh_token text Google refresh token
microsoft_token text Microsoft access token
microsoft_refresh_token text Microsoft refresh token

The password column is also made nullable to support social-only users.


๐Ÿ”’ Security


๐Ÿงช Testing

Test Web Routes

Test API Routes


๐Ÿ› Troubleshooting

Issue: Package installs as dev-master instead of stable version

Problem: When running composer require emmanuel-saleem/social-auth, it installs dev-master instead of a stable version.

Solution:

  1. Specify version constraint explicitly:

  2. Or install specific version:

  3. Check your composer.json minimum-stability:

Issue: Composer cache directory not writable (Docker)

Problem:

Solution: Run composer with proper permissions or disable cache:

Issue: Laravel version conflict

Problem:

Solution: The package supports Laravel 9, 10, and 11. Check your Laravel version:

If you're on Laravel 8 or below, you need to upgrade Laravel or use an older version of Socialite.

Issue: "Class not found" error

Solution: Make sure to run composer dump-autoload

Issue: Microsoft OAuth "invalid_client" error

Problem:

Solution:

  1. Check your credentials in .env file:

  2. Verify in Azure Portal:

    • Go to your app registration โ†’ Overview
    • Copy the exact Application (client) ID
    • Go to Certificates & secrets โ†’ Copy the exact client secret
  3. Clear config cache:

Issue: Microsoft OAuth "userAudience" configuration error

Problem:

Solution: This happens when your Azure app is configured for "Personal Microsoft accounts only" but the OAuth request uses the /common endpoint.

Option 1: Change Azure App Configuration (Recommended)

  1. Go to Azure Portal โ†’ Your App Registration โ†’ Authentication
  2. Change "Supported account types" to "Accounts in any organizational directory and personal Microsoft accounts"
  3. This allows the /common endpoint to work

Option 2: Use Consumer Endpoint

  1. Keep "Personal Microsoft accounts only" in Azure
  2. Set in your .env:

  3. Clear config cache:

Issue: Role dropdown not saving selected value

Problem: The role selected from the dropdown is not being saved to the database.

Solution: This was fixed in the latest version. Make sure you're using the updated package and clear caches:

The package now properly merges form data in the correct order: payload โ†’ user_defaults โ†’ extra (where extra overrides defaults).

Issue: Routes not working

Solution: Clear route cache:

Issue: "redirect_uri_mismatch"

Solution: Ensure your redirect URIs in .env match exactly with those in Google/Microsoft console

Issue: Token creation fails

Solution: Make sure:

  1. Laravel Sanctum is installed
  2. User model has HasApiTokens trait
  3. Migrations have run

Issue: CORS errors in API

Solution: Configure CORS in config/cors.php:


๐Ÿ“š Documentation


๐Ÿ›ฃ๏ธ Roadmap


๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

This package is open-sourced software licensed under the MIT license.


๐Ÿ‘จโ€๐Ÿ’ป Author

Emmanuel Saleem


๐Ÿ™ Acknowledgments


๐Ÿ“ž Support

If you encounter any issues or have questions:

  1. Check the OAUTH_API_GUIDE.md
  2. Review Troubleshooting section
  3. Check existing GitHub Issues
  4. Create a new issue with detailed information

Made with โค๏ธ for the Laravel community dodcumeiton link mirsoft https://learn.microsoft.com/en-us/graph/auth-register-app-v2


All versions of social-auth with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.1|^8.2|^8.3
laravel/framework Version ^8.0|^9.0|^10.0|^11.0
laravel/socialite Version ^4.4|^5.0
socialiteproviders/microsoft Version ^4.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 emmanuel-saleem/social-auth contains the following files

Loading the files please wait ...