English
English
简体中文
Contact Us
Register
Log In
layoutIndex

Login with Third-Party Account

Last Updated on : 2022-05-20 05:53:02download

Prerequisites

To enable login with an account of a third-party platform, you must configure App ID and App Secret in the Third-Party Login Support section on the Tuya IoT Development Platform.

Login with Third-Party Account

Then, you must develop the app as required by the third party, get the login code, and then call the login API method provided by Tuya Smart Life App SDK.

Login with Facebook account

API description

TuyaHomeSdk.getUserInstance().loginByFacebook(String phoneCode, String token, ILoginCallback callback);

Parameters

Parameter Description
phoneCode The country code. Example: 86.
token The token granted by Facebook to enable login.

Login with OAuth 2.0

Open Authorization (OAuth) is an open standard for access delegation, commonly used as a way for internet users to grant websites or applications access to their information on other websites, but without giving them the passwords or sharing all data content.

API description

The OAuth 2.0 API method is a common method for login. The type of OAuth 2.0 login is indicated by a parameter passed in.

void thirdLogin(String countryCode, String accessToken, String type, String extraInfo, ILoginCallback callback)

Parameters

Parameter Description
countryCode The country code. Example: 86.
accessToken The token granted for login.
type The type of OAuth 2.0 login. For example, ap indicates login with an Apple account and gg indicates login with a Google account.
extraInfo The additional information.
callback The callback.

Example

TuyaHomeSdk.getUserInstance().thirdLogin("your_country_code","auth2_token","auth2_type","{"info_key":"info_value"}", new ILoginCallback() {
    @Override
    public void onSuccess(User user) {

    }
    @Override
    public void onError(String code, String error) {

    }
});

Login with Google account

In view of the deployment of Google’s global network services, we recommend that users registered in mainland China do not log in with a Google account.

API description

After successful authorization, the OAuth 2.0 API method returns parameters such as Token and extraInfo to enable login.

Parameters

Parameter Description
countryNumberCode The country code. Example: 86.
accessToken The idToken granted by Google.
type The type of OAuth 2.0 login. Set the value to gg.
extraInfo {“pubVersion”: 1}
callback The callback.

Example

TuyaHomeSdk.getUserInstance().thirdLogin(countryNumberCode,token,"gg","{\"pubVersion\":1}", new ILoginCallback() {
    @Override
    public void onSuccess(User user) {

    }
    @Override
    public void onError(String code, String error) {

    }
});

Login with WeChat account

API description

TuyaHomeSdk.getUserInstance().loginByWechat(String countryCode, String code, ILoginCallback callback);

Parameters

Parameter Description
countryCode The country code. Example: 86.
code The code granted by WeChat to enable login.
callback The callback.

For login to the app using WeChat accounts, we recommend that you allow only WeChat accounts registered with China mobile phone numbers (+86) to be used for login. For WeChat accounts registered with mobile phone numbers in other countries or regions, the users might access WeChat services managed inside mainland China when these users are located outside mainland China, which may pose compliance risks of cross-border data transfers. As the data controller, you shall be aware of and bear the compliance risks posed by potential cross-border data transfers.

Login with Tencent QQ account

API description

TuyaHomeSdk.getUserInstance().loginByQQ(String countryCode, String userId, String accessToken, ILoginCallback callback);

Parameters

Parameter Description
countryCode The country code. Example: 86.
userId The userId granted by Tencent QQ to enable login.
accessToken The accessToken granted by Tencent QQ to enable login.
callback The callback.

For login to the app using Tencent QQ accounts, we recommend that you allow only Tencent QQ accounts registered with China mobile phone numbers (+86) to be used for login. For Tencent QQ accounts registered with mobile phone numbers in other countries or regions, the users might access Tencent QQ services managed inside mainland China when these users are located outside mainland China, which may pose compliance risks of cross-border data transfers. As the data controller, you shall be aware of and bear the compliance risks posed by potential cross-border data transfers.