我安装了PayPal SDK2.13.3,设置了客户机id、环境等。我在仪表板中为我的应用程序激活了Log In with PayPal。
现在代码:
PayPalAuthorization auth = data.getParcelableExtra( PayPalProfileSharingActivity.EXTRA_RESULT_AUTHORIZATION );
JSONObject json = auth.toJSONObject();
Logg.i( this, "payPal auth = " + json );给出的结果如下:
{"client":{"environment":"sandbox","paypal_sdk_version":"2.13.3","platform":"Android","product_name":"PayPal-Android-SDK"},"response":{"code":"blablah"},"response_type":"authorization_code"}我想在这里将字段定义为作用域:
Set<String> scopes = new HashSet<>( Arrays.asList( PAYPAL_SCOPE_OPENID, PAYPAL_SCOPE_PROFILE, PAYPAL_SCOPE_EMAIL ) );
i.putExtra( PayPalProfileSharingActivity.EXTRA_REQUESTED_SCOPES, new PayPalOAuthScopes( scopes ) );怎么才能做到这一点?我应该发出另一个请求吗?
发布于 2016-03-12 14:21:55
因此,经过研究发现,实现PayPal登录的最好方法是将第二部分移植到服务器上。
在设备上获得user content和"response":{"code":"blablah"}之后,最好将code发送到应该发生以下请求的服务器:
curl -v https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "{client-id}:{secret}" \
-d "grant_type=client_credentials"然后:
curl 'https://api.paypal.com/v1/oauth2/token' \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: Basic QWZVa...==" \
-d 'grant_type=refresh_token&refresh_token=MFYQ...'根据server.md和http://developer.paypal.com/docs/integration/direct/make-your-first-call/#get-an-access-token
https://stackoverflow.com/questions/35905029
复制相似问题