【发布时间】:2014-05-01 19:02:05
【问题描述】:
我正在使用signpost for OAuth 从 Magento 服务器访问数据。我已经阅读了相同的各种教程,并且达到了我们打开浏览器以便用户可以输入他的凭据的地步。但是,根据我的要求,我必须自动化这部分。
因此,用户不应获得浏览器页面。我在服务器端 (Magento) 完成了这个设置,我点击 URL 并返回到回调页面。我想通过我在 Android 中的程序来做同样的事情。
我已经尝试了以下,
consumer = new CommonsHttpOAuthConsumer(KEY, Secret);
provider = new CommonsHttpOAuthProvider(OAUTH_INIT_URL,ACCESS_TOKEN_URL, AUTHORIZE_URL);
try {
provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);
Log.d("Tokens" , consumer.getToken() + " -- " + consumer.getTokenSecret());
}
我得到了请求令牌。但我不知道如何绕过下一步。我尝试直接访问 AccessToken(我很愚蠢)provider.retrieveAccessToken(consumer, "myCallback://callback"); 但没有运气,它最终出现在
oauth.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match.
我非常感谢任何帮助,因为我从过去 3 天开始就一直坚持这一点。请告诉我是否需要提供更多数据。
【问题讨论】:
-
嗨 atul,您找到解决方案了吗?我也面临同样的问题。我必须使用 oauth 进行网络服务,不想打开浏览器。
-
很遗憾没有。我最终使用了 Magento 的 Rest API。让我们看看我们是否得到任何帮助。我也会检查我的上一份工作。
-
如果用户不去浏览器页面,他将如何向magento服务器提供他的凭据?
-
嘿 atul 和 @NiravBhandari 找到了一些解决方案??
-
@pushpendra - 不,兄弟,最终不得不切换到 REST api
标签: android oauth android-networking signpost android-embedded-api