2727use OCP \IAppConfig ;
2828use OCP \ICertificateManager ;
2929use OCP \IConfig ;
30+ use OCP \IURLGenerator ;
3031use OCP \OCM \Exceptions \OCMArgumentException ;
3132use OCP \OCM \Exceptions \OCMProviderException ;
3233use OCP \OCM \IOCMDiscoveryService ;
@@ -114,6 +115,7 @@ class DAV extends Common {
114115 protected ISignatureManager $ signatureManager ;
115116 protected OCMSignatoryManager $ signatoryManager ;
116117 protected IAppConfig $ appConfig ;
118+ protected IURLGenerator $ urlGenerator ;
117119
118120 /** @var int */
119121 private $ timeout ;
@@ -182,6 +184,7 @@ public function __construct(array $parameters) {
182184 $ this ->signatureManager = Server::get (ISignatureManager::class);
183185 $ this ->signatoryManager = Server::get (OCMSignatoryManager::class);
184186 $ this ->appConfig = Server::get (IAppConfig::class);
187+ $ this ->urlGenerator = Server::get (IURLGenerator::class);
185188 }
186189
187190 protected function init (): void {
@@ -204,16 +207,17 @@ protected function init(): void {
204207 }
205208
206209 $ client = $ this ->httpClientService ->newClient ();
210+ $ clientId = parse_url ($ this ->urlGenerator ->getAbsoluteURL ('/ ' ), PHP_URL_HOST );
207211 $ payload = [
208212 'grant_type ' => 'authorization_code ' ,
209- 'client_id ' => ' receiver.example.org ' ,
213+ 'client_id ' => $ clientId ,
210214 'code ' => $ this ->user ,
211215 ];
212216
213217 $ options = [
214- 'body ' => json_encode ($ payload ),
218+ 'body ' => http_build_query ($ payload ),
215219 'headers ' => [
216- 'Content-Type ' => 'application/json ' ,
220+ 'Content-Type ' => 'application/x-www-form-urlencoded ' ,
217221 ],
218222 'timeout ' => 10 ,
219223 'connect_timeout ' => 10 ,
0 commit comments