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


PHP Authorizer::getAuthCodeRequestParams方法代码示例

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


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

示例1: issueAuthorize

 /**
  * Issue request with the Auth Code Grant.
  *
  * @param  Illuminate\Http\Request $request
  * @return Response
  */
 public function issueAuthorize(Request $request)
 {
     $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 ($request->input('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 ($request->input('deny') !== null) {
         $redirectUri = Authorizer::authCodeRequestDeniedRedirectUri();
     }
     return Redirect::to($redirectUri);
 }
开发者ID:yeets,项目名称:lumen-api,代码行数:21,代码来源:OAuthController.php

示例2: view

    return view('auth.login');
});
Route::post('auth/login', function () {
    if (Auth::attempt(Input::only('email', 'password'))) {
        return Redirect::intended('oauth');
    }
});
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());
开发者ID:helei112g,项目名称:laravel-oauth,代码行数:31,代码来源:routes.php


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