當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Authorizer::issueAuthCode方法代碼示例

本文整理匯總了PHP中LucaDegasperi\OAuth2Server\Facades\Authorizer::issueAuthCode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Authorizer::issueAuthCode方法的具體用法?PHP Authorizer::issueAuthCode怎麽用?PHP Authorizer::issueAuthCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在LucaDegasperi\OAuth2Server\Facades\Authorizer的用法示例。


在下文中一共展示了Authorizer::issueAuthCode方法的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: 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


注:本文中的LucaDegasperi\OAuth2Server\Facades\Authorizer::issueAuthCode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。