@@ -416,10 +416,9 @@ public function dispatchExAppInit(ExApp $exApp): void {
416
416
) . '/init ' ;
417
417
418
418
$ options = [
419
- 'headers ' => [
420
- 'Accept ' => 'application/json ' ,
421
- 'Content-Type ' => 'application/json ' ,
422
- ],
419
+ 'Accept ' => 'application/json ' ,
420
+ 'Content-Type ' => 'application/json ' ,
421
+ 'headers ' => $ this ->buildAppAPIAuthHeaders (null , null , $ exApp ),
423
422
'nextcloud ' => [
424
423
'allow_local_address ' => true ,
425
424
],
@@ -560,13 +559,7 @@ public function requestToExApp(
560
559
$ exApp ->getPort ()) . $ route ;
561
560
562
561
$ options = [
563
- 'headers ' => [
564
- 'AA-VERSION ' => $ this ->appManager ->getAppVersion (Application::APP_ID , false ),
565
- 'EX-APP-ID ' => $ exApp ->getAppid (),
566
- 'EX-APP-VERSION ' => $ exApp ->getVersion (),
567
- 'AUTHORIZATION-APP-API ' => base64_encode ($ userId . ': ' . $ exApp ->getSecret ()),
568
- 'AA-REQUEST-ID ' => $ request instanceof IRequest ? $ request ->getId () : 'CLI ' ,
569
- ],
562
+ 'headers ' => $ this ->buildAppAPIAuthHeaders ($ request , $ userId , $ exApp ),
570
563
'nextcloud ' => [
571
564
'allow_local_address ' => true , // it's required as we are using ExApp appid as hostname (usually local)
572
565
],
@@ -603,6 +596,16 @@ public function requestToExApp(
603
596
}
604
597
}
605
598
599
+ private function buildAppAPIAuthHeaders (?IRequest $ request , ?string $ userId , ExApp $ exApp ): array {
600
+ return [
601
+ 'AA-VERSION ' => $ this ->appManager ->getAppVersion (Application::APP_ID , false ),
602
+ 'EX-APP-ID ' => $ exApp ->getAppid (),
603
+ 'EX-APP-VERSION ' => $ exApp ->getVersion (),
604
+ 'AUTHORIZATION-APP-API ' => base64_encode ($ userId . ': ' . $ exApp ->getSecret ()),
605
+ 'AA-REQUEST-ID ' => $ request instanceof IRequest ? $ request ->getId () : 'CLI ' ,
606
+ ];
607
+ }
608
+
606
609
/**
607
610
* @param string $protocol
608
611
* @param string $host
0 commit comments