Skip to content

Commit 7bd0350

Browse files
authored
Update env variables in AppIdentity (#75)
1 parent 0888551 commit 7bd0350

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/Api/AppIdentity/AppIdentityService.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,9 @@ private static function getAccessTokenUncached($scopes) {
245245
* @return string The application id of the app.
246246
*/
247247
public static function getApplicationId() {
248-
$app_id = getenv("APPLICATION_ID");
249-
$psep = strpos($app_id, self::PARTITION_SEPARATOR);
250-
if ($psep > 0) {
251-
$app_id = substr($app_id, $psep + 1);
252-
}
253-
return $app_id;
248+
$appid_arr = explode('~', getenv('GAE_APPLICATION'));
249+
$appid = $appid_arr[1];
250+
return $appid;
254251
}
255252

256253
/**
@@ -260,7 +257,7 @@ public static function getApplicationId() {
260257
* application, or FALSE if the call failed.
261258
*/
262259
public static function getDefaultVersionHostname() {
263-
return getenv("DEFAULT_VERSION_HOSTNAME");
260+
return getenv('HTTP_X_APPENGINE_DEFAULT_VERSION_HOSTNAME');
264261
}
265262

266263
/**

tests/Api/AppIdentity/AppIdentityServiceTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,25 +372,25 @@ public function testGetAccessTokenServiceNotAllowed() {
372372
}
373373

374374
public function testGetApplicationId() {
375-
putenv("APPLICATION_ID=simple-app-id");
375+
putenv("GAE_APPLICATION=part~simple-app-id");
376376
$this->assertEquals("simple-app-id",
377377
AppIdentityService::getApplicationId());
378378

379-
putenv("APPLICATION_ID=domain.com:domain-app-id");
379+
putenv("GAE_APPLICATION=part~domain.com:domain-app-id");
380380
$this->assertEquals("domain.com:domain-app-id",
381381
AppIdentityService::getApplicationId());
382382

383-
putenv("APPLICATION_ID=part~partition-app-id");
383+
putenv("GAE_APPLICATION=part~partition-app-id");
384384
$this->assertEquals("partition-app-id",
385385
AppIdentityService::getApplicationId());
386386

387-
putenv("APPLICATION_ID=part~domain.com:display");
387+
putenv("GAE_APPLICATION=part~domain.com:display");
388388
$this->assertEquals("domain.com:display",
389389
AppIdentityService::getApplicationId());
390390
}
391391

392392
public function testGetDefaultVersionHostname() {
393-
putenv("DEFAULT_VERSION_HOSTNAME=my-app.appspot.com");
393+
putenv("HTTP_X_APPENGINE_DEFAULT_VERSION_HOSTNAME=my-app.appspot.com");
394394
$this->assertEquals("my-app.appspot.com",
395395
AppIdentityService::getDefaultVersionHostname());
396396
}

0 commit comments

Comments
 (0)