ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.phpmaileroauthgoogle.php
Go to the documentation of this file.
1 <?php
28 {
29  private $oauthUserEmail = '';
30  private $oauthRefreshToken = '';
31  private $oauthClientId = '';
32  private $oauthClientSecret = '';
33 
40  public function __construct(
41  $UserEmail,
42  $ClientSecret,
43  $ClientId,
44  $RefreshToken
45  ) {
46  $this->oauthClientId = $ClientId;
47  $this->oauthClientSecret = $ClientSecret;
48  $this->oauthRefreshToken = $RefreshToken;
49  $this->oauthUserEmail = $UserEmail;
50  }
51 
52  private function getProvider()
53  {
55  'clientId' => $this->oauthClientId,
56  'clientSecret' => $this->oauthClientSecret
57  ]);
58  }
59 
60  private function getGrant()
61  {
62  return new \League\OAuth2\Client\Grant\RefreshToken();
63  }
64 
65  private function getToken()
66  {
67  $provider = $this->getProvider();
68  $grant = $this->getGrant();
69  return $provider->getAccessToken($grant, ['refresh_token' => $this->oauthRefreshToken]);
70  }
71 
72  public function getOauth64()
73  {
74  $token = $this->getToken();
75  return base64_encode("user=" . $this->oauthUserEmail . "\001auth=Bearer " . $token . "\001\001");
76  }
77 }
__construct( $UserEmail, $ClientSecret, $ClientId, $RefreshToken)