WSO2IS IDP 代理无法获取移动应用程序的访问令牌
WSO2IS IDP Proxy unable to obtain access token for mobile app
我一直在为 android(http://wso2.com/library/articles/2014/07/sso-for-native-mobile-applications-with-wso2-identity-server/) 测试 WSO2 身份服务器 IDP 代理。我成功地设置了 IDP 代理应用程序并进行了测试。但是,当我设置给定的示例应用程序(azone 和 eBuy)时,我遇到了一些错误,我无法理解为什么每次登录这些示例应用程序时令牌都会返回 NULL。以下是错误日志:
09-10 11:04:55.020: D/dalvikvm(19024): GC_FOR_ALLOC freed 83K, 12%
free 9589K/10856K, paused 22ms, total 22ms 09-10 11:04:55.020:
I/dalvikvm-heap(19024): Grow heap (frag case) to 11.990MB for
1544896-byte allocation 09-10 11:04:55.045: D/dalvikvm(19024):
GC_FOR_ALLOC freed <1K, 11% free 11098K/12368K, paused 23ms, total
23ms 09-10 11:04:55.195: D/dalvikvm(19024): GC_FOR_ALLOC freed 2K, 10%
free 12516K/13788K, paused 15ms, total 15ms 09-10 11:04:55.310:
D/libEGL(19024): loaded /system/lib/egl/libEGL_mali.so 09-10
11:04:55.315: D/libEGL(19024): loaded
/system/lib/egl/libGLESv1_CM_mali.so 09-10 11:04:55.320:
D/libEGL(19024): loaded /system/lib/egl/libGLESv2_mali.so 09-10
11:04:55.325: E/(19024): Device driver API match 09-10 11:04:55.325:
E/(19024): Device driver API version: 23 09-10 11:04:55.325:
E/(19024): User space API version: 23 09-10 11:04:55.325: E/(19024):
mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Wed Oct 9 21:05:57 KST
2013 09-10 11:04:55.395: D/OpenGLRenderer(19024): Enabling debug mode
0 09-10 11:05:09.585: D/IdentityProxyActivity(19024): starting IDP
Proxy App 09-10 11:05:10.220: W/IInputConnectionWrapper(19024):
showStatusIcon on inactive InputConnection 09-10 11:05:21.770:
D/IdentityProxyActivity(19024): starting IdentityProxyActivity
onActivityResult 09-10 11:05:21.775: D/AccessTokenHandler(19024):
d3b276fc3665350818f18f521f7ae4 09-10 11:05:21.790:
D/ServerUtilities(19024): Posting '{grant_type=authorization_code,
redirect_uri=http://wso2.com, scope=openid,
code=d3b276fc3665350818f18f521f7ae4}' to
https://172.18.64.178:9443/oauth2/token 09-10 11:05:21.795:
D/ServerUtilities(19024): Posting
'grant_type=authorization_code&redirect_uri=http://wso2.com&scope=openid&code=d3b276fc3665350818f18f521f7ae4' to https://172.18.64.178:9443/oauth2/token 09-10 11:05:22.150:
D/AccessTokenHandler(19024): {"error":"Internal Server
Error","error_description":"Internal Server Error"} 09-10
11:05:22.150: D/AccessTokenHandler(19024): Internal Server Error 09-10
11:05:22.150: D/AccessTokenHandler(19024): Internal Server Error 09-10
11:05:22.150: D/AndroidRuntime(19024): Shutting down VM 09-10
11:05:22.150: W/dalvikvm(19024): threadid=1: thread exiting with
uncaught exception (group=0x41c38700) 09-10 11:05:22.155:
E/AndroidRuntime(19024): FATAL EXCEPTION: main 09-10 11:05:22.155:
E/AndroidRuntime(19024): java.lang.NullPointerException 09-10
11:05:22.155: E/AndroidRuntime(19024): at
org.wso2.mobile.idp.proxy.IdentityProxy.receiveAccessToken(IdentityProxy.java:60)
09-10 11:05:22.155: E/AndroidRuntime(19024): at
org.wso2.mobile.idp.proxy.handlers.AccessTokenHandler$NetworkCallTask.onPostExecute(AccessTokenHandler.java:132)
09-10 11:05:22.155: E/AndroidRuntime(19024): at
org.wso2.mobile.idp.proxy.handlers.AccessTokenHandler$NetworkCallTask.onPostExecute(AccessTokenHandler.java:65)
09-10 11:05:22.155: E/AndroidRuntime(19024): at
android.os.AsyncTask.finish(AsyncTask.java:631) 09-10 11:05:22.155:
E/AndroidRuntime(19024): at
android.os.AsyncTask.access0(AsyncTask.java:177) 09-10
11:05:22.155: E/AndroidRuntime(19024): at
android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
09-10 11:05:22.155: E/AndroidRuntime(19024): at
android.os.Handler.dispatchMessage(Handler.java:99) 09-10
11:05:22.155: E/AndroidRuntime(19024): at
android.os.Looper.loop(Looper.java:176) 09-10 11:05:22.155:
E/AndroidRuntime(19024): at
android.app.ActivityThread.main(ActivityThread.java:5419) 09-10
11:05:22.155: E/AndroidRuntime(19024): at
java.lang.reflect.Method.invokeNative(Native Method) 09-10
11:05:22.155: E/AndroidRuntime(19024): at
java.lang.reflect.Method.invoke(Method.java:525) 09-10 11:05:22.155:
E/AndroidRuntime(19024): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
09-10 11:05:22.155: E/AndroidRuntime(19024): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 09-10
11:05:22.155: E/AndroidRuntime(19024): at
dalvik.system.NativeStart.main(Native Method)
此外,在测试 sdample app(eBuy) 时,除了 Logcat 中显示的上述错误外,Identity Server wso2carbon.log.
中没有显示任何错误。
您是否为 OauthCostants.java
中的客户 ID 和秘密输入了正确的值
在分析您的日志时,我发现您已成功完成授权代码授予类型的第一步,但由于某种原因,第二步(令牌请求)失败了。
- 您能看到 Identity Server 后端记录的任何异常吗?
- 与 https://172.18.64.178:9443/oauth2/token 的任何连接问题?
- 试试 http://172.18.64.178:9763/oauth2/token ?
Gayan,我终于解开了这个问题的谜团。当我按照你提到的方式卷曲时,我注意到了一种不同类型的错误。它显示 "error":"invalid_request","error_description":"Missing parameters: redirect_uri"。在对代理应用程序和示例应用程序(azone 和 eBuy)之间的 OauthConstants.java 进行一些检查之后。我注意到给出的示例应用程序的代码存在一些错误。对于示例应用程序,其中一个变量在 OauthConstants.java 中声明为 REDIRECT_URL 而不是 CALL_BACK_URL。一旦我根据SDK的要求更改为CALL_BACK_URL。一切正常。
我一直在为 android(http://wso2.com/library/articles/2014/07/sso-for-native-mobile-applications-with-wso2-identity-server/) 测试 WSO2 身份服务器 IDP 代理。我成功地设置了 IDP 代理应用程序并进行了测试。但是,当我设置给定的示例应用程序(azone 和 eBuy)时,我遇到了一些错误,我无法理解为什么每次登录这些示例应用程序时令牌都会返回 NULL。以下是错误日志:
09-10 11:04:55.020: D/dalvikvm(19024): GC_FOR_ALLOC freed 83K, 12% free 9589K/10856K, paused 22ms, total 22ms 09-10 11:04:55.020: I/dalvikvm-heap(19024): Grow heap (frag case) to 11.990MB for 1544896-byte allocation 09-10 11:04:55.045: D/dalvikvm(19024): GC_FOR_ALLOC freed <1K, 11% free 11098K/12368K, paused 23ms, total 23ms 09-10 11:04:55.195: D/dalvikvm(19024): GC_FOR_ALLOC freed 2K, 10% free 12516K/13788K, paused 15ms, total 15ms 09-10 11:04:55.310: D/libEGL(19024): loaded /system/lib/egl/libEGL_mali.so 09-10 11:04:55.315: D/libEGL(19024): loaded /system/lib/egl/libGLESv1_CM_mali.so 09-10 11:04:55.320: D/libEGL(19024): loaded /system/lib/egl/libGLESv2_mali.so 09-10 11:04:55.325: E/(19024): Device driver API match 09-10 11:04:55.325: E/(19024): Device driver API version: 23 09-10 11:04:55.325: E/(19024): User space API version: 23 09-10 11:04:55.325: E/(19024): mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Wed Oct 9 21:05:57 KST 2013 09-10 11:04:55.395: D/OpenGLRenderer(19024): Enabling debug mode 0 09-10 11:05:09.585: D/IdentityProxyActivity(19024): starting IDP Proxy App 09-10 11:05:10.220: W/IInputConnectionWrapper(19024): showStatusIcon on inactive InputConnection 09-10 11:05:21.770: D/IdentityProxyActivity(19024): starting IdentityProxyActivity onActivityResult 09-10 11:05:21.775: D/AccessTokenHandler(19024): d3b276fc3665350818f18f521f7ae4 09-10 11:05:21.790: D/ServerUtilities(19024): Posting '{grant_type=authorization_code, redirect_uri=http://wso2.com, scope=openid, code=d3b276fc3665350818f18f521f7ae4}' to https://172.18.64.178:9443/oauth2/token 09-10 11:05:21.795: D/ServerUtilities(19024): Posting 'grant_type=authorization_code&redirect_uri=http://wso2.com&scope=openid&code=d3b276fc3665350818f18f521f7ae4' to https://172.18.64.178:9443/oauth2/token 09-10 11:05:22.150: D/AccessTokenHandler(19024): {"error":"Internal Server Error","error_description":"Internal Server Error"} 09-10 11:05:22.150: D/AccessTokenHandler(19024): Internal Server Error 09-10 11:05:22.150: D/AccessTokenHandler(19024): Internal Server Error 09-10 11:05:22.150: D/AndroidRuntime(19024): Shutting down VM 09-10 11:05:22.150: W/dalvikvm(19024): threadid=1: thread exiting with uncaught exception (group=0x41c38700) 09-10 11:05:22.155: E/AndroidRuntime(19024): FATAL EXCEPTION: main 09-10 11:05:22.155: E/AndroidRuntime(19024): java.lang.NullPointerException 09-10 11:05:22.155: E/AndroidRuntime(19024): at org.wso2.mobile.idp.proxy.IdentityProxy.receiveAccessToken(IdentityProxy.java:60) 09-10 11:05:22.155: E/AndroidRuntime(19024): at org.wso2.mobile.idp.proxy.handlers.AccessTokenHandler$NetworkCallTask.onPostExecute(AccessTokenHandler.java:132) 09-10 11:05:22.155: E/AndroidRuntime(19024): at org.wso2.mobile.idp.proxy.handlers.AccessTokenHandler$NetworkCallTask.onPostExecute(AccessTokenHandler.java:65) 09-10 11:05:22.155: E/AndroidRuntime(19024): at android.os.AsyncTask.finish(AsyncTask.java:631) 09-10 11:05:22.155: E/AndroidRuntime(19024): at android.os.AsyncTask.access0(AsyncTask.java:177) 09-10 11:05:22.155: E/AndroidRuntime(19024): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644) 09-10 11:05:22.155: E/AndroidRuntime(19024): at android.os.Handler.dispatchMessage(Handler.java:99) 09-10 11:05:22.155: E/AndroidRuntime(19024): at android.os.Looper.loop(Looper.java:176) 09-10 11:05:22.155: E/AndroidRuntime(19024): at android.app.ActivityThread.main(ActivityThread.java:5419) 09-10 11:05:22.155: E/AndroidRuntime(19024): at java.lang.reflect.Method.invokeNative(Native Method) 09-10 11:05:22.155: E/AndroidRuntime(19024): at java.lang.reflect.Method.invoke(Method.java:525) 09-10 11:05:22.155: E/AndroidRuntime(19024): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 09-10 11:05:22.155: E/AndroidRuntime(19024): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 09-10 11:05:22.155: E/AndroidRuntime(19024): at dalvik.system.NativeStart.main(Native Method)
此外,在测试 sdample app(eBuy) 时,除了 Logcat 中显示的上述错误外,Identity Server wso2carbon.log.
中没有显示任何错误。您是否为 OauthCostants.java
中的客户 ID 和秘密输入了正确的值在分析您的日志时,我发现您已成功完成授权代码授予类型的第一步,但由于某种原因,第二步(令牌请求)失败了。
- 您能看到 Identity Server 后端记录的任何异常吗?
- 与 https://172.18.64.178:9443/oauth2/token 的任何连接问题?
- 试试 http://172.18.64.178:9763/oauth2/token ?
Gayan,我终于解开了这个问题的谜团。当我按照你提到的方式卷曲时,我注意到了一种不同类型的错误。它显示 "error":"invalid_request","error_description":"Missing parameters: redirect_uri"。在对代理应用程序和示例应用程序(azone 和 eBuy)之间的 OauthConstants.java 进行一些检查之后。我注意到给出的示例应用程序的代码存在一些错误。对于示例应用程序,其中一个变量在 OauthConstants.java 中声明为 REDIRECT_URL 而不是 CALL_BACK_URL。一旦我根据SDK的要求更改为CALL_BACK_URL。一切正常。