当前位置: 首页>>代码示例>>PHP>>正文


PHP Authorizer::issueAccessToken方法代码示例

本文整理汇总了PHP中LucaDegasperi\OAuth2Server\Facades\Authorizer::issueAccessToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Authorizer::issueAccessToken方法的具体用法?PHP Authorizer::issueAccessToken怎么用?PHP Authorizer::issueAccessToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LucaDegasperi\OAuth2Server\Facades\Authorizer的用法示例。


在下文中一共展示了Authorizer::issueAccessToken方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createToken

 public function createToken(Request $request)
 {
     $json = $request->json()->all();
     $request = new Request();
     $request->request->replace($json);
     Authorizer::setRequest($request);
     return $this->respond(Authorizer::issueAccessToken());
 }
开发者ID:kidshenlong,项目名称:comic-cloud-lumen,代码行数:8,代码来源:AuthController.php

示例2: callback

 /**
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Laravel\Lumen\Http\Redirector
  */
 public function callback(Request $request)
 {
     $state = $request->get('state');
     $sessionState = Session::get('google.oauth2state');
     $code = $request->get('code');
     if ($request->get('error')) {
         $request->session()->flash('error', 'auth.error');
         return redirect(route('auth.loginForm'));
     }
     if (empty($state) || $state !== $sessionState) {
         Session::forget('google.oauth2state');
         $request->session()->flash('error', 'auth.error');
         return redirect(route('auth.loginForm'));
     }
     $token = $this->provider->getAccessToken('authorization_code', ['code' => $code]);
     try {
         /** @var GoogleUser $ownerDetails */
         $ownerDetails = $this->provider->getResourceOwner($token);
         $email = $ownerDetails->getEmail();
         // if we already have the email in DB we log the user
         if (!$this->repository->exists(['email' => $email])) {
             $lastName = $ownerDetails->getLastName();
             $firstName = $ownerDetails->getFirstName();
             $this->createUser($firstName, $lastName, $email);
         }
         // we try to logged in the user with the email and the google oauth access token
         Input::merge(['client_id' => Config::get('oauth2.web_client.client_id')]);
         Input::merge(['client_secret' => Config::get('oauth2.web_client.client_secret')]);
         Input::merge(['grant_type' => 'google']);
         Input::merge(['username' => $email]);
         Input::merge(['password' => $token->getToken()]);
         try {
             Authorizer::issueAccessToken();
             return redirect('/');
         } catch (\Exception $e) {
             $request->session()->flash('error', 'auth.login_error');
             return redirect(route('auth.loginForm'));
         }
     } catch (ModelNotValid $e) {
         $request->session()->flash('error', 'auth.error');
         Log::warn($e->getMessage());
         return redirect(route('auth.loginForm'));
     } catch (\Exception $e) {
         $request->session()->flash('error', 'auth.error');
         Log::warn($e->getMessage());
         return redirect(route('auth.loginForm'));
     }
 }
开发者ID:ndrx-io,项目名称:elude,代码行数:52,代码来源:Google.php

示例3: function

*
* Routes For Authenticate Client : Line 47
*
* Method 			: Post 
*
* Parameter Send 	: [grant_type => 'client_credentials', client_id => 'xx', client_secret => 'xx']
*
* Returned JSend 	: [token => [access_token => 'xx', token_type => 'Bearer', expires_in => 00]]
*/
$app->post('/oauth/access_token', function () {
    $issue['token'] = \LucaDegasperi\OAuth2Server\Facades\Authorizer::issueAccessToken();
    if (\Illuminate\Support\Facades\Auth::check()) {
        $issue['me'] = \Illuminate\Support\Facades\Auth::user()->toArray();
        return new \App\Libraries\JSend('success', (array) $issue);
    } else {
        return new \App\Libraries\JSend('error', (array) ['No Data'], 'User invalid :( ');
    }
});
$app->post('/oauth/client/access_token', function () {
    $issue['token'] = \LucaDegasperi\OAuth2Server\Facades\Authorizer::issueAccessToken();
    return new \App\Libraries\JSend('success', (array) $issue);
});
$app->group(['middleware' => 'oauth', 'namespace' => 'App\\Http\\Controllers'], function ($app) {
    // ------------------------------------------------------------------------------------
    // Gettin' Me
    // ------------------------------------------------------------------------------------
    $app->get('/me', function () {
        $user = \LucaDegasperi\OAuth2Server\Facades\Authorizer::getResourceOwnerId();
        return $user;
    });
});
开发者ID:ThunderID,项目名称:SHOP-API,代码行数:31,代码来源:routes_authorized.php

示例4: function

});
Route::get('oauth/authorize', ['as' => 'oauth.authorize.get', 'middleware' => ['check-authorization-params', 'auth'], function () {
    // display a form where the user can authorize the client to access it's data
    $authParams = Authorizer::getAuthCodeRequestParams();
    $formParams = array_except($authParams, 'client');
    $formParams['client_id'] = $authParams['client']->getId();
    return View::make('oauth.authorization-form', ['params' => $formParams, 'client' => $authParams['client']]);
}]);
Route::post('oauth/authorize', ['as' => 'oauth.authorize.post', 'middleware' => ['csrf', 'check-authorization-params', 'auth'], function () {
    $params = Authorizer::getAuthCodeRequestParams();
    $params['user_id'] = Auth::user()->id;
    $redirectUri = '';
    // if the user has allowed the client to access its data, redirect back to the client with an auth code
    if (Input::get('approve') !== null) {
        $redirectUri = Authorizer::issueAuthCode('user', $params['user_id'], $params);
    }
    // if the user has denied the client to access its data, redirect back to the client with an error message
    if (Input::get('deny') !== null) {
        $redirectUri = Authorizer::authCodeRequestDeniedRedirectUri();
    }
    return Redirect::to($redirectUri);
}]);
Route::post('oauth/access_token', ['as' => 'access_token', function () {
    header('Content-Type:application/json; charset=utf-8');
    return Response::json(Authorizer::issueAccessToken());
}]);
Route::get('/callback', function () {
    if (Input::has('code')) {
        return view('callback');
    }
});
开发者ID:helei112g,项目名称:laravel-oauth,代码行数:31,代码来源:routes.php

示例5: view

    return view('welcome');
});
//Testing Routes
Route::get('/test-oauth', function () {
    return view('test.integracaoOAuth');
});
Route::get('/test-payment', function () {
    return view('test.payment');
});
//User Routes
Route::get('user/info', ['middleware' => 'oauth', function () {
    return Authorizer::getResourceOwnerId();
}]);
//Products Routes
Route::get('products/info', function () {
    return response()->json(Product::all());
});
//Laravel Socialite Login, Data and Login Routes
Route::get('service/{providerName}/login', 'ServiceAuthController@redirectToProvider');
Route::get('service/{providerName}/data', 'ServiceAuthController@handleProviderData');
//Payment Routes
Route::post('payment/{service}/post', 'PaymentController@postPayment');
Route::get('payment/{service}/status', 'PaymentController@getPaymentStatus');
Route::get('payment/{service}/cancel', 'PaymentController@getPaymentCancel');
//Oauth Routes
Route::post('service/login', function () {
    return response()->json(Authorizer::issueAccessToken());
});
Route::post('oauth/access_token', function () {
    return response()->json(Authorizer::issueAccessToken());
});
开发者ID:alfoalfr,项目名称:laravel-dev-env,代码行数:31,代码来源:routes.php

示例6: issueAccessToken

 /**
  * Issue oauth acess token & refresh access token.
  *
  * @return Response
  */
 public function issueAccessToken()
 {
     return Authorizer::issueAccessToken();
 }
开发者ID:yeets,项目名称:lumen-api,代码行数:9,代码来源:OAuthController.php

示例7: function

| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$app->get('/', function () use($app) {
    return $app->version();
});
$app->get('/hello', function () use($app) {
    return 'Hello! It\'s me';
});
$app->get('/example', function () use($app) {
    return view('example');
});
$app->post('oauth/access_token', function () use($app) {
    $token = Authorizer::issueAccessToken();
    return response()->json($token);
});
$app->get('oauth/authorize', ['as' => 'oauth.authorize.get', 'middleware' => ['check-authorization-params', 'auth'], function () {
    $authParams = Authorizer::getAuthCodeRequestParams();
    $formParams = array_except($authParams, 'client');
    $formParams['client_id'] = $authParams['client']->getId();
    $formParams['scope'] = implode(config('oauth2.scope_delimiter'), array_map(function ($scope) {
        return $scope->getId();
    }, $authParams['scopes']));
    return View::make('authorization', ['params' => $formParams, 'client' => $authParams['client']]);
}]);
$app->post('oauth/authorize', ['as' => 'oauth.authorize.post', 'middleware' => ['csrf', 'check-authorization-params', 'auth'], function () {
    $params = Authorizer::getAuthCodeRequestParams();
    $params['user_id'] = 6;
    //Auth::user()->id;
开发者ID:pheelixx,项目名称:autho,代码行数:31,代码来源:routes.php

示例8: tokenById

 /**
  * Log the given user ID into the application.
  *
  * @param mixed $id
  *
  * @return \Illuminate\Contracts\Auth\Authenticatable
  *
  * @internal param bool $remember
  */
 public function tokenById($id)
 {
     $user = $this->provider->retrieveById($id);
     if (!is_null($user)) {
         $this->request['user_id'] = $user->id;
         $this->request['grant_type'] = 'forced';
         return Authorizer::issueAccessToken();
     }
     return false;
 }
开发者ID:everywell,项目名称:laravel-essentials,代码行数:19,代码来源:OAuthGuard.php


注:本文中的LucaDegasperi\OAuth2Server\Facades\Authorizer::issueAccessToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。