예제 #1
0
 /**
  * Get a OneDrive token.
  *
  * @param bool $system If true, get a system API ser token instead of the user's token.
  * @param int|null $userid The userid to get a token for. If null, the current user will be used.
  * @return \local_o365\oauth2\token A OneDrive token object.
  */
 protected function get_onedrive_token($system = false, $userid = null)
 {
     global $USER;
     $resource = \local_o365\rest\onedrive::get_resource();
     if ($system === true) {
         return \local_o365\oauth2\systemtoken::instance(null, $resource, $this->clientdata, $this->httpclient);
     } else {
         $userid = !empty($userid) ? $userid : $USER->id;
         return \local_o365\oauth2\token::instance($userid, $resource, $this->clientdata, $this->httpclient);
     }
 }
예제 #2
0
 /**
  * Get a OneDrive token.
  *
  * @return \local_o365\oauth2\token A OneDrive token object.
  */
 protected function get_onedrive_token()
 {
     global $USER;
     $resource = \local_o365\rest\onedrive::get_resource();
     return \local_o365\oauth2\token::instance($USER->id, $resource, $this->clientdata, $this->httpclient);
 }