2
我想從基於Oauth 1.0身份驗證的Android調用Context.io API。如何在Android中調用Oauth 1.0 API?
您能否請我建議我如何創建Oauth1.0標準請求或請求,任何人都可以向我提供該標準的Oauth1.0請求示例示例代碼。
非常感謝。
我想從基於Oauth 1.0身份驗證的Android調用Context.io API。如何在Android中調用Oauth 1.0 API?
您能否請我建議我如何創建Oauth1.0標準請求或請求,任何人都可以向我提供該標準的Oauth1.0請求示例示例代碼。
非常感謝。
您可以使用scriblejava庫來訪問Oauth 1.0 2腳API。
在Android Studio中應用鐺添加以下的依賴:
compile 'org.scribe:scribe:1.3.5'
而且只需使用下面的代碼:
String consumerKey = "XXXX"; //api key
String consumerSecret = "XXXX"; //api secret
String requestUrl = "your context.io request url";
OAuthService service = new ServiceBuilder()
.provider(OAuthProvider.class)
.apiKey(consumerKey)
.apiSecret(consumerSecret)
.build();
OAuthRequest request = new OAuthRequest(Verb.GET, requestUrl);
Token accessToken = new Token("", ""); //not required for context.io
service.signRequest(accessToken, request);
Response response = request.send();
Log.d("OAuthTask",response.getBody());
希望它幫助!
如何將OAuthProvider.class集成到provider()方法中?我想集成woocommerce api。 –
嗨Mrugesh。你有答案嗎? – Nishith
你能解釋一下關於'OAuthProvider.class'嗎? –