コード例 #1
0
ファイル: Authentication.php プロジェクト: Pleio/pleio_rest
 /**
  * @SWG\Post(
  *     path="/oauth/v2/token",
  *     tags={"authentication"},
  *     summary="Request a new access token.",
  *     description="Request a new access token for the specific user.",
  *     produces={"application/json"},
  *     @SWG\Parameter(
  *         name="username",
  *         in="query",
  *         description="The username of the specific user.",
  *         required=true,
  *         type="string",
  *         @SWG\Items(type="string")
  *     ),
  *     @SWG\Parameter(
  *         name="password",
  *         in="query",
  *         description="The password of the specific user.",
  *         required=true,
  *         type="string",
  *         @SWG\Items(type="string")
  *     ),
  *     @SWG\Parameter(
  *         name="client_id",
  *         in="query",
  *         description="The id of the client application.",
  *         required=true,
  *         type="string",
  *         @SWG\Items(type="string")
  *     ),
  *     @SWG\Parameter(
  *         name="client_secret",
  *         in="query",
  *         description="The secret of the client application.",
  *         required=true,
  *         type="string",
  *         @SWG\Items(type="string")
  *     ),
  *     @SWG\Response(
  *         response=200,
  *         description="Succesful operation."
  *     ),
  * )
  */
 public function getToken($request, $response, $args)
 {
     $factory = new \PleioRest\AuthenticationServerFactory();
     $server = $factory->getServer();
     $authRequest = \OAuth2\Request::createFromGlobals();
     $authResponse = $server->handleTokenRequest($authRequest);
     $response = $response->withStatus($authResponse->getStatusCode());
     $response->write(json_encode($authResponse->getParameters(), JSON_PRETTY_PRINT));
     return $response;
 }
コード例 #2
0
ファイル: User.php プロジェクト: Pleio/pleio_rest
 /**
  * @SWG\Post(
  *     path="/api/users/me/deregister_push",
  *     security={{"oauth2": {"all"}}},
  *     tags={"user"},
  *     summary="Deregister application for push notifications.",
  *     description="Deregister an application to receive push notifications of activities.",
  *     produces={"application/json"},
  *     @SWG\Parameter(
  *         name="service",
  *         in="query",
  *         description="The service (gcm, apns or wns)",
  *         required=true,
  *         type="string",
  *         @SWG\Items(type="string")
  *     ),
  *     @SWG\Parameter(
  *         name="device_id",
  *         in="query",
  *         description="The unique device ID registered with register_push.",
  *         required=true,
  *         type="string",
  *         @SWG\Items(type="string")
  *     ),
  *     @SWG\Response(
  *         response=200,
  *         description="Succesful operation."
  *     )
  * )
  */
 public function deregisterPush($request, $response, $args)
 {
     $factory = new \PleioRest\AuthenticationServerFactory();
     $server = $factory->getServer();
     $accessData = $server->getAccessTokenData(\OAuth2\Request::createFromGlobals());
     $vars = $request->getParsedBody();
     $service = $vars['service'];
     $device_id = $vars['device_id'];
     if (!in_array($service, array('gcm', 'apns', 'wns'))) {
         return $response->withStatus(404);
     }
     $handler = new \PleioRest\Services\PushNotificationHandler();
     $handler->removeSubscription(elgg_get_logged_in_user_entity(), $accessData['client_id'], $service, $device_id);
 }