File tree 3 files changed +100
-4
lines changed
src/DMS/Service/Meetup/Config
3 files changed +100
-4
lines changed Original file line number Diff line number Diff line change 15
15
"guzzlehttp/guzzle-services" : " ^1.1" ,
16
16
"gimler/guzzle-description-loader" : " ^0.0.4"
17
17
},
18
-
18
+
19
19
"require-dev" : {
20
20
"symfony/css-selector" : " ~2.2" ,
21
21
"symfony/dom-crawler" : " ~2.2" ,
22
22
"symfony/console" : " ~2.2" ,
23
23
"phpunit/phpunit" : " ^4.8" ,
24
24
"symfony/var-dumper" : " ~2.6" ,
25
25
"mathiasgrimm/arraypath" : " ~1.3" ,
26
- "guzzlehttp/oauth-subscriber" : " ^0.3.0"
26
+ "guzzlehttp/oauth-subscriber" : " ^0.3.0" ,
27
+ "kamermans/guzzle-oauth2-subscriber" : " ^1.0"
27
28
},
28
29
"suggest" : {
29
- "guzzlehttp/oauth-subscriber" : " For authenticating with Oauth1.0"
30
+ "guzzlehttp/oauth-subscriber" : " For authenticating with Oauth1.0" ,
31
+ "kamermans/guzzle-oauth2-subscriber" : " For authenticating with OAuth2"
30
32
},
31
33
32
34
"autoload" : {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace DMS \Service \Meetup \Config ;
4
+
5
+ use kamermans \OAuth2 \GrantType \GrantTypeInterface ;
6
+ use kamermans \OAuth2 \OAuth2Middleware ;
7
+
8
+ final class OAuth2Config implements ClientConfig
9
+ {
10
+ /**
11
+ * @var GrantTypeInterface
12
+ */
13
+ protected $ grantType ;
14
+
15
+ /**
16
+ * @var bool
17
+ */
18
+ protected $ shouldSignAllRequests ;
19
+
20
+ /**
21
+ * @param GrantTypeInterface $grantType
22
+ * @param bool $shouldSignAllRequests
23
+ */
24
+ public function __construct (GrantTypeInterface $ grantType , bool $ shouldSignAllRequests = true )
25
+ {
26
+ $ this ->grantType = $ grantType ;
27
+ $ this ->shouldSignAllRequests = $ shouldSignAllRequests ;
28
+ }
29
+
30
+ /**
31
+ * @return callable[]
32
+ */
33
+ public function getMiddleware (): array
34
+ {
35
+ return [
36
+ 'oauth2 ' => new OAuth2Middleware ($ this ->grantType )
37
+ ];
38
+ }
39
+
40
+ /**
41
+ * @return string[]
42
+ */
43
+ public function getClientConfig (): array
44
+ {
45
+ $ config = [];
46
+
47
+ if ($ this ->shouldSignAllRequests ) {
48
+ $ config ['auth ' ] = 'oauth ' ;
49
+ }
50
+
51
+ return $ config ;
52
+ }
53
+ }
You can’t perform that action at this time.
0 commit comments