SHARESDK implementing third-party logins (Android implementation steps)

Source: Internet
Author: User

Before entering the topic, I would like to explain what is a "third-party login". The so-called third-party login, is to use the user on the third-party platform has an existing account to quickly complete their application's login or registration function. And the third-party platform here, generally has a large number of users of the platform, such as the domestic Sina Weibo, QQ space, foreign Facebook, Twitter and so on. A third-party login is not a specific interface, but a thought or set of steps.
To implement a third-party login, you first need to select a third-party platform. Sina Weibo and QQ space are good choices, these platforms have a large number of users, but also open the API for us to call access. But the same open API is not a good choice, because the API only supports sharing, does not support authorization authentication or access to user data. So to achieve a third-party login, the platform you choose needs to have at least:
1, open the API
2. Have access to user information or at least authorization verification
In fact, the share SDK has supported more than 10 such sub-platforms, fully enough for you to choose to use.

After choosing a good platform, now think about the following questions:
Does your app have a standalone account system?
This issue is an important criterion for interface selection during third-party login. If you choose "yes", it means that your app only needs users from third-party platforms, not their account verification capabilities-that is, "data, no features." And if you choose "No", then you are actually "want function, no data (user)". For the Share SDK, your entry method is Showuser (null), and the latter is authorize (). Then I'll explain the two ways of access.

Start with a simple word. For the "to function, do not data" scenario, the steps are as follows:
1. User triggers a third-party login event
2. Call Weibo.getdb (). Getweiboid () request the user ID on this platform
3, if the user ID exists, it is considered that the user is a legitimate user, allow access to the system; otherwise call authorize ()
4, authorize () method will guide the user to enter the account password on the authorization page, then the target platform will verify the user
5. If the OnComplete () method is called back, it indicates that the authorization is successful and directs the user to enter the system
6, otherwise prompt error, call the Removeaccount () method, delete the possible authorization cache data

Then the steps to "want data, do not function":
1. User triggers a third-party login event
2, Showuser (NULL) request information of authorized user (this process may involve authorization action)
3, if the OnComplete () method is called back, its parameters hashmap into the login process of your application
4, otherwise prompt error, call the Removeaccount () method, delete the possible authorization cache data
5. Login when client sends user ID in user profile to server
6, the service side to determine the user is a registered user, then guide the user into the system, otherwise return a specific error code
7, the client receives the "unregistered user" error code, the user information into your application register process
8, register in the user profile to select your application registration required fields, and submit to the server registration
9, the server to complete the user registration, the success of the feedback client to guide users into the system
10, otherwise prompt error, call the Removeaccount () method, delete the possible authorization cache data

To write this article, I made a demo based on the share SDK 1.2.0 and chose Sina Weibo, QQ space, Facebook and Twitter as a demonstration platform. Since I do not have the server and account system that I can use, I just demonstrated the above "to function, not data". But it can be easily seen that this is actually the second case of simplification, and the second is the remaining steps, more of your app's client and server between the login and registration operations, and the Share SDK has no relationship.

SHARESDK implementing third-party logins (Android implementation steps)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.