From c8983b35a0b0bb082b76fe3c4ce7d555bf7c0760 Mon Sep 17 00:00:00 2001 From: Malachi Soord Date: Fri, 5 Dec 2014 18:12:19 +0100 Subject: [PATCH 1/2] Fixed example API hasScope reference --- examples/relational/api.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/relational/api.php b/examples/relational/api.php index fededdf8..f4d02202 100644 --- a/examples/relational/api.php +++ b/examples/relational/api.php @@ -59,11 +59,11 @@ $router->get('/users', function (Request $request) use ($server) { 'name' => $result['name'], ]; - if ($server->hasScope('email')) { + if ($server->getAccessToken()->hasScope('email')) { $user['email'] = $result['email']; } - if ($server->hasScope('photo')) { + if ($server->getAccessToken()->hasScope('photo')) { $user['photo'] = $result['photo']; } @@ -87,11 +87,11 @@ $router->get('/users/{username}', function (Request $request, $args) use ($serve 'name' => $result[0]['name'], ]; - if ($server->hasScope('email')) { + if ($server->getAccessToken()->hasScope('email')) { $user['email'] = $result[0]['email']; } - if ($server->hasScope('photo')) { + if ($server->getAccessToken()->hasScope('photo')) { $user['photo'] = $result[0]['photo']; } From 774341c3462189ba1e10fc7d94b2eedfaf2bd696 Mon Sep 17 00:00:00 2001 From: Malachi Soord Date: Fri, 5 Dec 2014 18:24:24 +0100 Subject: [PATCH 2/2] Fixed tokeninfo --- examples/relational/api.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/relational/api.php b/examples/relational/api.php index f4d02202..52a1ff05 100644 --- a/examples/relational/api.php +++ b/examples/relational/api.php @@ -34,12 +34,14 @@ $router = new \Orno\Route\RouteCollection(); // GET /tokeninfo $router->get('/tokeninfo', function (Request $request) use ($server) { + $accessToken = $server->getAccessToken(); + $session = $server->getSessionStorage()->getByAccessToken($accessToken); $token = [ - 'owner_id' => $server->getOwnerId(), - 'owner_type' => $server->getOwnerType(), - 'access_token' => $server->getAccessToken(), - 'client_id' => $server->getClientId(), - 'scopes' => $server->getScopes(), + 'owner_id' => $session->getOwnerId(), + 'owner_type' => $session->getOwnerType(), + 'access_token' => $accessToken, + 'client_id' => $session->getClient()->getId(), + 'scopes' => $accessToken->getScopes(), ]; return new Response(json_encode($token));