PayPal Permissions Service - 2012 User's Guide Page 21

  • Download
  • Add to my manuals
  • Print
  • Page
    / 80
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 20
PayPal Permissions Service May 2012 21
Using the Permissions Service
Generating Signatures for the Authentication Header
2
Signature=tLWUfZU9Np/7qgPqWF1LMIWjY1s=
Timestamp=1285744515
Use the values to construct the header as follows:
X-PAYPAL-AUTHORIZATION=timestamp=12857 44515,
token=5wZptMaHXQfihLKZFscuGjeKOPqQrlfHFPqRc1QlItX3vYi6,
signature=tL WUfZU9Np/7qgPqWF1L MIWjY1s=
Java Example
The PayPal Java SDK provides a method for creating the X-PAYPAL-AUTHORIZATION
header. See the getAuthHeader method in the OauthSignature.java file of the
com.paypal.sdk.util package in paypal_base.jar.
import java.util.Iterator;
import java.util.Map;
import com.paypal.sdk.util.OAuthSignature;
import com.paypal.sdk.util.OAuthSignature.HTTPMethod;
public class TestOauthSignature {
private static String apiUserName = "..._biz_api1.gmail.com";
private static String apiPassword = "1255077037";
private static String accessToken = "2WhQDDM4...";
private static String tokenSecret = "j0YhbTgcy.K5VjpQa7Ru8oM...";
private static HTTPMethod httpMethod = OAuthSignature.HTTPMethod.POST;
private static String scriptURI = "https://api.sandbox.paypal.com/nvp";
private static Map queryParams = null;
public static void main(String[] args) {
try{
Map map = OAuthSignature.getAuthHeader(apiUserName, apiPassword,
accessToken, tokenSecret, httpMethod, scriptURI, queryParams);
// Display Signature and Timestamp to console.
Iterator itr = map.entrySet().iterator();
while(itr.hasNext()){
Map.Entry entry = (Map.Entry)itr.next();
System.out.println(entry.getKey() + ": " + entry.getValue());
}
}catch (Exception e) {
// handle exception
}
}
}
Page view 20
1 2 ... 16 17 18 19 20 21 22 23 24 25 26 ... 79 80

Comments to this Manuals

No comments