simpleusername/laravel-oauth2 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

simpleusername/laravel-oauth2

最新稳定版本:0.4.13

Composer 安装命令:

composer require simpleusername/laravel-oauth2

包简介

Authorize users in your application with multiple OAuth 2.0 providers.

README 文档

README

This is a port to Laravel 4 of Talor Otwell's Laravel-oAuth2 bundle. Which he based on the CodeIgniter OAuth2 Spark maintained by Phil Sturgeon

Authorize users with your application in a driver-base fashion meaning one implementation works for multiple OAuth 2 providers. This is only to authenticate onto OAuth2 providers and not to build an OAuth2 service.

Note that this package ONLY provides the authorization mechanism. There's an example controller below.

Installation via Composer

Add this to you composer.json file, in the require object;

"SimpleUsername/laravel-oauth2": "0.4.*"

After that, run composer install to install Laravel OAuth 2.0.

Currently Supported

  • Facebook
  • Foursquare
  • GitHub
  • Google
  • iHealth
  • Jawbone
  • Mailchimp
  • Misfit
  • Moves
  • Runkeeper
  • Strava
  • Uber
  • Under Armour
  • Windows Live
  • YouTube

Usage Example

http://example.com/auth/session/facebook

use OAuth2\OAuth2;
use OAuth2\Token_Access;
use OAuth2\Exception as OAuth2_Exception;

public function action_session($provider)
{
	$provider = OAuth2::provider($provider, array(
		'id' => 'your-client-id',
		'secret' => 'your-client-secret',
	));

	if ( ! isset($_GET['code']))
	{
		// By sending no options it'll come back here
		return $provider->authorize();
	}
	else
	{
		// Howzit?
		try
		{
			$params = $provider->access($_GET['code']);
			
        		$token = new Token_Access(array(
        			'access_token' => $params->access_token
        		));
        		$user = $provider->get_user_info($token);

			// Here you should use this information to A) look for a user B) help a new user sign up with existing data.
			// If you store it all in a cookie and redirect to a registration page this is crazy-simple.
			echo "<pre>";
			var_dump($user);
		}
		
		catch (OAuth2_Exception $e)
		{
			show_error('That didnt work: '.$e);
		}
	}
}

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 173
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-10-27