如何从 PayPal 授权中获取用户数据
How to get user data out of PayPalAuthorization
我安装了 PayPal SDK 2.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 ) );
有什么方法可以做到这一点?我应该发出另一个请求吗?
因此,经过一些研究后发现,实现 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...'
根据http://github.com/paypal/PayPal-Android-SDK/blob/master/docs/profile_sharing_server.md and http://developer.paypal.com/docs/integration/direct/make-your-first-call/#get-an-access-token
我安装了 PayPal SDK 2.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 ) );
有什么方法可以做到这一点?我应该发出另一个请求吗?
因此,经过一些研究后发现,实现 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...'
根据http://github.com/paypal/PayPal-Android-SDK/blob/master/docs/profile_sharing_server.md and http://developer.paypal.com/docs/integration/direct/make-your-first-call/#get-an-access-token