2 namespace PayPal\Auth\Oauth;
3 //PayPal specific modification
4 //Method to be called for generating signature
8 public function genSign($key, $secret, $token, $tokenSecret, $httpMethod, $endpoint) {
10 $authServer = new OAuthServer(new MockOAuthDataStore());
11 $hmac_method = new OAuthSignatureMethodHmacSha1();
12 $authServer->add_signature_method($hmac_method);
14 $sig_method = $hmac_method;
15 $authConsumer = new OAuthConsumer($key, $secret, NULL);
17 $authToken = new OAuthToken($token, $tokenSecret);
19 //$params is the query param array which is required only in the httpMethod is "GET"
21 //TODO: set the Query parameters to $params if httpMethod is "GET"
23 $acc_req = OAuthRequest::from_consumer_and_token($authConsumer, $authToken, $httpMethod, $endpoint, $params);
24 $acc_req->sign_request($sig_method,$authConsumer, $authToken);
25 return OAuthutil::parseQueryString($acc_req);
28 public static function generateFullAuthString($key, $secret, $token, $tokenSecret, $httpMethod, $endpoint) {
29 $authSignature = new AuthSignature();
30 $response = $authSignature->genSign($key, $secret, $token, $tokenSecret, $httpMethod, $endpoint);
31 return "token=" . $token .
32 ",signature=" . $response['oauth_signature'] .
33 ",timestamp=" . $response['oauth_timestamp'];