-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathXOAuth2.php
More file actions
40 lines (34 loc) · 738 Bytes
/
Copy pathXOAuth2.php
File metadata and controls
40 lines (34 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace DirectoryTree\ImapEngine\Authentication;
use DirectoryTree\ImapEngine\Authenticator;
class XOAuth2 implements Authenticator
{
/**
* Constructor.
*/
public function __construct(
protected string $user,
protected string $token,
) {}
/**
* {@inheritDoc}
*/
public function mechanism(): string
{
return 'XOAUTH2';
}
/**
* {@inheritDoc}
*/
public function initialResponse(): string
{
return "user=$this->user\1auth=Bearer $this->token\1\1";
}
/**
* {@inheritDoc}
*/
public function respond(string $challenge): string
{
return $challenge === '' ? $this->initialResponse() : '';
}
}