oauth_for_android
openkk
13年前
<p>这是一个为 Android 程序开发的 OAuth 库/应用,以便使用 Content Providers 来存储 OAuth 数据。</p> <p>示例代码:</p> <p>添加服务提供者</p> <pre class="brush:java; toolbar: true; auto-links: false;">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)</pre> <p>重定向用户到OAuth 激活</p> <pre class="brush:java; toolbar: true; auto-links: false;">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);</pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1324257491828" target="_blank">http://www.open-open.com/lib/view/home/1324257491828</a></p> <p></p>