oauth_for_android
這是一個為 Android 程序開發的 OAuth 庫/應用,以便使用 Content Providers 來存儲 OAuth 數據。
示例代碼:
添加服務提供者
ContentValues values = new ContentValues(); values.put('request_token_url', 'http://mysite.com/request_token'); values.put('access_token_url', 'http://mysite.com/access_token'); values.put('authorize_url', 'http://mysite.com/authorize'); values.put('consumer_key', 'myconsumerkey'); values.put('consumer_secret', 'mysecret'); getContentResolver().insert(Uri.parse('content://com.novoda.oauth.providers/registry'), values)
重定向用戶到OAuth 激活
Intent intent = new Intent(); Bundle extras = new Bundle(); HashMap<String, String> value = new HashMap<String, String>(); intent.setAction("com.novoda.oauth.action.OAUTH_CALL"); intent.setData(Uri.parse("content://com.novoda.oauth.provider.OAuth/registry"), ID_OF_THE_SERVICE)); extras.putString("endpoint", ENDPOINT_URI); extras.putSerializable("parameters", value); intent.putExtras(extras); startActivityForResult(intent, RESULT_CALLBACK_ID);
本文由用戶 openkk 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!