Skip to content

Commit 946c823

Browse files
committed
Merge pull request facebookarchive#90 from mattynoce/master
If appsecret_proof param is sent in code, do not override in sdk
2 parents 55f179f + b1c72d1 commit 946c823

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/base_facebook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ protected function _oauthRequest($url, $params) {
930930
$params['access_token'] = $this->getAccessToken();
931931
}
932932

933-
if (isset($params['access_token'])) {
933+
if (isset($params['access_token']) && !isset($params['appsecret_proof'])) {
934934
$params['appsecret_proof'] = $this->getAppSecretProof($params['access_token']);
935935
}
936936

tests/tests.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,31 @@ public function testMissingAccessTokenInCodeExchangeIsIgnored() {
13581358
$this->assertFalse($stub->publicGetAccessTokenFromCode('c', ''));
13591359
}
13601360

1361+
public function testAppsecretProofNoParams() {
1362+
$fb = new FBRecordMakeRequest(array(
1363+
'appId' => self::APP_ID,
1364+
'secret' => self::SECRET,
1365+
));
1366+
$token = $fb->getAccessToken();
1367+
$proof = $fb->publicGetAppSecretProof($token);
1368+
$params = array();
1369+
$fb->api('/mattynoce', $params);
1370+
$requests = $fb->publicGetRequests();
1371+
$this->assertEquals($proof, $requests[0]['params']['appsecret_proof']);
1372+
}
1373+
1374+
public function testAppsecretProofWithParams() {
1375+
$fb = new FBRecordMakeRequest(array(
1376+
'appId' => self::APP_ID,
1377+
'secret' => self::SECRET,
1378+
));
1379+
$proof = 'foo';
1380+
$params = array('appsecret_proof' => $proof);
1381+
$fb->api('/mattynoce', $params);
1382+
$requests = $fb->publicGetRequests();
1383+
$this->assertEquals($proof, $requests[0]['params']['appsecret_proof']);
1384+
}
1385+
13611386
public function testExceptionConstructorWithErrorCode() {
13621387
$code = 404;
13631388
$e = new FacebookApiException(array('error_code' => $code));
@@ -1949,6 +1974,10 @@ protected function makeRequest($url, $params, $ch=null) {
19491974
public function publicGetRequests() {
19501975
return $this->requests;
19511976
}
1977+
1978+
public function publicGetAppSecretProof($access_token) {
1979+
return $this->getAppSecretProof($access_token);
1980+
}
19521981
}
19531982

19541983
class FBPublic extends TransientFacebook {

0 commit comments

Comments
 (0)