1313
1414namespace chillerlan \OAuth \Providers ;
1515
16- use chillerlan \HTTP \Utils \QueryUtil ;
1716use chillerlan \OAuth \Core \{
1817 AccessToken , AuthenticatedUser , ClientCredentials , CSRFToken , OAuth2Interface ,
1918 OAuth2Provider , TokenInvalidate , TokenRefresh , UserInfo
2019};
21- use Psr \Http \Message \ResponseInterface ;
2220use function sprintf ;
23- use const PHP_QUERY_RFC1738 ;
2421
2522/**
2623 * @see https://github.com/reddit-archive/reddit/wiki/OAuth2
@@ -76,6 +73,8 @@ class Reddit extends OAuth2Provider implements ClientCredentials, CSRFToken, Tok
7673 'User-Agent ' => self ::USER_AGENT ,
7774 ];
7875
76+ public const USES_BASIC_AUTH_IN_ACCESS_TOKEN_REQUEST = true ;
77+
7978 protected string $ authorizationURL = 'https://www.reddit.com/api/v1/authorize ' ;
8079 protected string $ accessTokenURL = 'https://www.reddit.com/api/v1/access_token ' ;
8180 protected string $ apiURL = 'https://oauth.reddit.com/api ' ;
@@ -84,34 +83,6 @@ class Reddit extends OAuth2Provider implements ClientCredentials, CSRFToken, Tok
8483 protected string |null $ applicationURL = 'https://www.reddit.com/prefs/apps/ ' ;
8584 protected string |null $ userRevokeURL = 'https://www.reddit.com/settings/privacy ' ;
8685
87- /**
88- * @inheritDoc
89- */
90- protected function getAccessTokenRequestBodyParams (string $ code ):array {
91- return [
92- 'code ' => $ code ,
93- 'grant_type ' => 'authorization_code ' ,
94- 'redirect_uri ' => $ this ->options ->callbackURL ,
95- ];
96- }
97-
98- /**
99- * @inheritDoc
100- */
101- protected function sendAccessTokenRequest (string $ url , array $ body ):ResponseInterface {
102-
103- $ request = $ this ->requestFactory
104- ->createRequest ('POST ' , $ url )
105- ->withHeader ('Accept-Encoding ' , 'identity ' )
106- ->withHeader ('Content-Type ' , 'application/x-www-form-urlencoded ' )
107- ->withBody ($ this ->streamFactory ->createStream (QueryUtil::build ($ body , PHP_QUERY_RFC1738 )))
108- ;
109-
110- $ request = $ this ->addBasicAuthHeader ($ request );
111-
112- return $ this ->http ->sendRequest ($ request );
113- }
114-
11586 /**
11687 * @inheritDoc
11788 * @codeCoverageIgnore
0 commit comments