Skip to content

Commit cdca591

Browse files
BenjaminBenjamin
authored andcommitted
Made sending of REST API key conditional on it's presence to avoid sending an unnecessary header to a server that may no longer require a client key.
Passing 'null' instead of an actual key will result in that header being omitted. Passing a string will retain existing functionality for servers that require it.
1 parent 08505c5 commit cdca591

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ ParseClient::initialize( $app_id, $rest_key, $master_key );
4848
ParseClient::setServerURL('https://my-parse-server.com','parse');
4949
```
5050

51+
If your server does not use or require a REST key you may initialize the ParseClient as follows, safely omitting the REST key:
52+
53+
```php
54+
ParseClient::initialize( $app_id, null, $master_key );
55+
// Users of Parse Server will need to point ParseClient at their remote URL and Mount Point:
56+
ParseClient::setServerURL('https://my-parse-server.com','parse');
57+
```
58+
5159
Usage
5260
-----
5361

src/Parse/ParseClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final class ParseClient
3737
/**
3838
* The REST API Key.
3939
*
40-
* @var string
40+
* @var string|null
4141
*/
4242
private static $restKey;
4343

@@ -455,7 +455,7 @@ public static function _getRequestHeaders($sessionToken, $useMasterKey)
455455
}
456456
if ($useMasterKey) {
457457
$headers[] = 'X-Parse-Master-Key: '.self::$masterKey;
458-
} else {
458+
} else if(isset(self::$restKey)) {
459459
$headers[] = 'X-Parse-REST-API-Key: '.self::$restKey;
460460
}
461461
if (self::$forceRevocableSession) {

0 commit comments

Comments
 (0)