Commit 2cc073a 1 parent 0235deb commit 2cc073a Copy full SHA for 2cc073a
File tree 3 files changed +15
-17
lines changed
3 files changed +15
-17
lines changed Original file line number Diff line number Diff line change 12
12
* ----------------------------------------------------------------------------------
13
13
*
14
14
* @author lanlin
15
- * @change 2021/09/22
15
+ * @change 2021/11/23
16
16
*/
17
17
class Hosted
18
18
{
@@ -80,19 +80,16 @@ public function sendAuthorizationCode(string $code): array
80
80
{
81
81
V::doValidate (V::stringType ()->notEmpty (), $ code );
82
82
83
- $ query = [
84
- 'code ' => $ code ,
85
- 'grant_type ' => 'authorization_code ' ,
86
- ];
87
-
88
- $ client = [
83
+ $ params = [
84
+ 'code ' => $ code ,
85
+ 'grant_type ' => 'authorization_code ' ,
89
86
'client_id ' => $ this ->options ->getClientId (),
90
87
'client_secret ' => $ this ->options ->getClientSecret (),
91
88
];
92
89
93
90
return $ this ->options
94
91
->getSync ()
95
- ->setQuery ( \array_merge ( $ query , $ client ) )
92
+ ->setFormParams ( $ params )
96
93
->post (API ::LIST ['oAuthToken ' ]);
97
94
}
98
95
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ public function __construct(Options $options)
37
37
// ------------------------------------------------------------------------------
38
38
39
39
/**
40
- * echo challenge to validate webhook
40
+ * echo challenge to validate webhook (for fpm mode)
41
41
*
42
42
* TIPS: you'd better use the output method from your framework.
43
43
*/
@@ -58,7 +58,7 @@ public function echoChallenge(): void
58
58
// ------------------------------------------------------------------------------
59
59
60
60
/**
61
- * get notification & parse it
61
+ * get notification & parse it (for fpm mode)
62
62
*
63
63
* @return array
64
64
* [
@@ -87,7 +87,7 @@ public function getNotification(): array
87
87
// ------------------------------------------------------------------------------
88
88
89
89
/**
90
- * webhook X-Nylas-Signature header verification
90
+ * webhook X-Nylas-Signature header verification (for other mode)
91
91
*
92
92
* @see https://docs.nylas.com/reference#receiving-notifications
93
93
*
Original file line number Diff line number Diff line change 12
12
* @see https://developer.nylas.com/docs/api/#tag--Hosted-Authentication
13
13
*
14
14
* @author lanlin
15
- * @change 2021/09/22
15
+ * @change 2021/11/23
16
16
*
17
17
* @internal
18
18
*/
@@ -42,15 +42,16 @@ public function testSendAuthorizationCode(): void
42
42
$ code = $ this ->faker ->postcode ;
43
43
44
44
$ this ->mockResponse ([
45
- 'client_id ' => $ this ->faker ->uuid ,
46
- 'client_secret ' => $ this ->faker ->email ,
47
- 'grant_type ' => 'authorization_code ' ,
48
- 'code ' => $ this ->faker ->postcode ,
45
+ 'provider ' => 'gmail ' ,
46
+ 'token_type ' => 'bearer ' ,
47
+ 'account_id ' => $ this ->faker ->md5 ,
48
+ 'access_token ' => $ this ->faker ->md5 ,
49
+ 'email_address ' => $ this ->faker ->email ,
49
50
]);
50
51
51
52
$ data = $ this ->client ->Authentication ->Hosted ->sendAuthorizationCode ($ code );
52
53
53
- $ this ->assertTrue (!empty ($ data ['client_id ' ]));
54
+ $ this ->assertTrue (!empty ($ data ['access_token ' ]));
54
55
}
55
56
56
57
// ------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments