Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

oauth-4-laravel

> 编程语言
Open source

OAuth Service Provider for Laravel 4

678 stars0 likes0 views
WebsiteGitHub

About

OAuth Service Provider for Laravel 4

OAuth wrapper for Laravel 4

oauth-4-laravel is a simple laravel 4 service provider (wrapper) for Lusitanian/PHPoAuthLib which provides oAuth support in PHP 5.3+ and is very easy to integrate with any project which requires an oAuth client.


  • Supported services
  • Installation
  • Registering the Package
  • Configuration
  • Usage
  • Basic usage
  • More usage examples

Supported services

The library supports both oAuth 1.x and oAuth 2.0 compliant services. A list of currently implemented services can be found below. More services will be implemented soon.

Included service implementations:

  • OAuth1
    • BitBucket
    • Etsy
    • FitBit
    • Flickr
    • Scoop.it!
    • Tumblr
    • Twitter
    • Xing
    • Yahoo
  • OAuth2
    • Amazon
    • BitLy
    • Box
    • Dailymotion
    • Dropbox
    • Facebook
    • Foursquare
    • GitHub
    • Google
    • Harvest
    • Heroku
    • Instagram
    • LinkedIn
    • Mailchimp
    • Microsoft
    • PayPal
    • Pocket
    • Reddit
    • RunKeeper
    • SoundCloud
    • Vkontakte
    • Yammer
  • more to come!

To learn more about Lusitanian/PHPoAuthLib go here

Installation

Use composer to install this package.

$ composer require artdarek/oauth-4-laravel:dev-master

Registering the Package

Register the service provider within the providers array found in app/config/app.php:

php
'providers' => array(
	// ...
	
	'Artdarek\OAuth\OAuthServiceProvider'
)

Add an alias within the aliases array found in app/config/app.php:

php
'aliases' => array(
	// ...
	
	'OAuth' => 'Artdarek\OAuth\Facade\OAuth',
)

Configuration

There are two ways to configure oauth-4-laravel. You can choose the most convenient way for you. You can use package config file which can be generated through command line by artisan (option 1) or you can simply create a config file called oauth-4-laravel.php in your app\config\ directory (option 2).

Option 1

Create configuration file for package using artisan command

$ php artisan config:publish artdarek/oauth-4-laravel

Option 2

Create configuration file manually in config directory app/config/oauth-4-laravel.php and put there code from below.

php
 'Session', 

	/**
	 * Consumers
	 */
	'consumers' => array(

		/**
		 * Facebook
		 */
		'Facebook' => array(
		    'client_id'     => '',
		    'client_secret' => '',
		    'scope'         => array(),
		),		

	)

);

Credentials

Add your credentials to app/config/packages/artdarek/oauth-4-laravel/config.php or app/config/oauth-4-laravel.php (depending on which option of configuration you choose)

The Storage attribute is optional and defaults to Session. Other options.

Usage

Basic usage

Just follow the steps below and you will be able to get a service class object with this one rule:

php
$fb = OAuth::consumer('Facebook');

Optionally, add a second parameter with the URL which the service needs to redirect to, otherwise it will redirect to the current URL.

php
$fb = OAuth::consumer('Facebook','http://url.to.redirect.to');

Usage examples

Facebook:

Configuration: Add your Facebook credentials to app/config/packages/artdarek/oauth-4-laravel/config.php

php
'Facebook' => array(
    'client_id'     => 'Your Facebook client ID',
    'client_secret' => 'Your Facebook Client Secret',
    'scope'         => array('email','read_friendlists','user_online_presence'),
),	

In your Controller use the following code:

…

Google:

Configuration: Add your Google credentials to app/config/packages/artdarek/oauth-4-laravel/config.php

php
'Google' => array(
    'client_id'     => 'Your Google client ID',
    'client_secret' => 'Your Google Client Secret',
    'scope'         => array('userinfo_email', 'userinfo_profile'),
),	

In your Controller use the following code:

…

Twitter:

Configuration: Add your Twitter credentials to app/config/packages/artdarek/oauth-4-laravel/config.php

php
'Twitter' => array(
    'client_id'     => 'Your Twitter client ID',
    'client_secret' => 'Your Twitter Client Secret',
    // No scope - oauth1 doesn't need scope
),	

In your Controller use the following code:

…

Linkedin:

Configuration: Add your Linkedin credentials to app/config/packages/artdarek/oauth-4-laravel/config.php

php
'Linkedin' => array(
    'client_id'     => 'Your Linkedin API ID',
    'client_secret' => 'Your Linkedin API Secret',
),	

In your Controller use the following code:

…

Yahoo:

Configuration: Add your Yahoo credentials to app/config/packages/artdarek/oauth-4-laravel/config.php

php
'Yahoo' => array(
            'client_id'     => 'Your Yahoo API KEY',
            'client_secret' => 'Your Yahoo API Secret',  
),	

In your Controller use the following code:

…

More usage examples:

For examples go here

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHP

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言