Using Android AccountManager for 3rd party OAuth2 authorization

跟風遠走 提交于 2019-12-05 11:42:18

This might be a rather late answer after all these 4 years, but let me give you a short reply.

You cannot and should not be installing third-party accounts for Oauth yourself. It is the job of those third-party OAuth providers such as Facebook or Twitter to implement AccountManager functionality and create their own account type. This is roughly guided at https://developer.android.com/training/id-auth/custom_auth.html.

There are several services, including OAuth providers such as Facebook, Twitter, WeChat, and etc, who register user accounts in AccountManager but I believe most of them just use it to implement SyncAdapter (which requires Account), not to provide OAuth functionality to third-party applications like your app.

I think Google allows you to use their APIs using the token acquired through AccountManager; the link you provide gives an example of using AccountManager for Tasks API. However, using the client library is a better option of achieving the same thing as described in https://developers.google.com/google-apps/tasks/quickstart/java#step_3_configure_the_project_build.

If the third-party OAuth provider does not provide you any SDKs or client libraries, you have no other choice but to use REST APIs they provide.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!