Guest User

DoorkeeperAdapter.php

a guest
Feb 22nd, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <?php
  2.  
  3. namespace OAuth\Plugin;
  4.  
  5. class DoorkeeperAdapter extends AbstractAdapter {
  6.  
  7.     /**
  8.      * Retrieve the user's data
  9.      *
  10.      * The array needs to contain at least 'user', 'mail', 'name' and optional 'grps'
  11.      *
  12.      * @return array
  13.      */
  14.     public function getUser() {
  15.         $JSON = new \JSON(JSON_LOOSE_TYPE);
  16.         $data = array();
  17.  
  18.         /** var OAuth\OAuth2\Service\Generic $this->oAuth */
  19.         $result = $JSON->decode($this->oAuth->request('https://esi.evetech.net/latest/swagger.json'));
  20.  
  21.         $data['user'] = 'eve-'.$result['character_id'];
  22.         $data['name'] = 'eve-'.$result['character_id'];
  23.         $data['mail'] = $result['character_id'];
  24.  
  25.         if( !empty($result['corporation_id']) )
  26.         {
  27.             $data['grps'] = $result['corporation_id'];
  28.         }
  29.         $data['grps'] = $result['corporation_id'];
  30.  
  31.         return $data;
  32.     }
  33.  
  34.     /**
  35.      * We make use of the "Generic" oAuth 2 Service as defined in
  36.      * phpoauthlib/src/OAuth/OAuth2/Service/Generic.php
  37.      *
  38.      * @return string
  39.      */
  40.     public function getServiceName() {
  41.         return 'Generic';
  42.     }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment