本文整理汇总了PHP中Authorization::setApplication方法的典型用法代码示例。如果您正苦于以下问题:PHP Authorization::setApplication方法的具体用法?PHP Authorization::setApplication怎么用?PHP Authorization::setApplication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authorization
的用法示例。
在下文中一共展示了Authorization::setApplication方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: callWithEitherScope
/**
* Verify call with scopes using OR logic
*
* @test
* @covers ::call
*
* @return void
*/
public function callWithEitherScope()
{
$storage = new \OAuth2\Storage\Memory(['access_tokens' => ['atokenvalue' => ['access_token' => 'atokenvalue', 'client_id' => 'a client id', 'user_id' => 'a user id', 'expires' => 99999999900, 'scope' => 'basicUser withPermission anExtraScope']]]);
$server = new \OAuth2\Server($storage, ['enforce_state' => true, 'allow_implicit' => false, 'access_lifetime' => 3600]);
\Slim\Environment::mock(['CONTENT_TYPE' => 'application/json', 'PATH_INFO' => '/foo']);
$slim = self::getSlimInstance();
$authorization = new Authorization($server);
$authorization->setApplication($slim);
$slim->get('/foo', $authorization->withRequiredScope(['superUser', ['basicUser', 'withPermission']]), function () {
});
$env = \Slim\Environment::getInstance();
$slim->request = new \Slim\Http\Request($env);
$slim->request->headers->set('Authorization', 'Bearer atokenvalue');
$slim->response = new \Slim\Http\Response();
$slim->run();
$this->assertSame(200, $slim->response->status());
$this->assertSame(['access_token' => 'atokenvalue', 'client_id' => 'a client id', 'user_id' => 'a user id', 'expires' => 99999999900, 'scope' => 'basicUser withPermission anExtraScope'], $slim->token);
}