目录

CLASS info
public class HuaweiIdAuthTool
HuaweiIdAuthTool提供静态实用方法,以获取、清除授权信息。

Public Method Summary

Return typeMethod name
static void

deleteAuthInfo(Context context, String accessToken)

清除本地缓存。

static void

deleteAuthInfo(Activity activity, String accessToken)

清除本地缓存。

static String

requestUnionId(Context context, String huaweiAccountName)

获取unionId。
static String

requestUnionId(Activity activity, String huaweiAccountName)

获取unionId。

static String

requestAccessToken(Context context, Account huaweiAccount, List<Scope> scopeList)

获取token。

static String

requestAccessToken(Activity activity, Account huaweiAccount, List<Scope> scopeList)

获取token。

static String

requestAccessToken(Context context, Account huaweiAccount, List<Scope> scopeList, Bundle extendInfo)

获取token。

static String

requestAccessToken(Activity activity, Account huaweiAccount, List<Scope> scopeList, Bundle 

extendInfo)

获取token。

static String

requestAccessToken(Context context, String huaweiAccountName, List<Scope> scopeList)

已废弃,建议使用requestAccessToken(Context context, Account huaweiAccount,  List<Scope> scopeList)代替。

static String

requestAccessToken(Activity activity, String huaweiAccountName, List<Scope> scopeList)

已废弃,建议使用requestAccessToken(Activity activity, Account huaweiAccount,  List<Scope> scopeList)代替。

static String

requestAccessToken(Context context, String huaweiAccountName, List<Scope> scopeList, Bundle extendInfo)

已废弃,建议使用requestAccessToken(Context context, Account huaweiAccount,  List<Scope> scopeList, Bundle extendInfo)代替。

static String

requestAccessToken(Activity activity, String huaweiAccountName, List<Scope> scopeList, Bundle extendInfo)

已废弃,建议使用requestAccessToken(Activity activity, Account huaweiAccount,  List<Scope> scopeList, Bundle extendInfo)代替。

Public Methods

Method
public static void deleteAuthInfo(Context context, String accessToken) throws HuaweiIdAuthException
清除本地缓存。
说明:
当传入参数为非Activity类型时,调用deleteAuthInfo接口会发生异常,不会弹出UI交互界面提示用户处理。例如:当HMS Core (APK)不符合帐号服务的版本要求时,便会抛出“hms apk version is low”异常信息,此时需要手动升级HMS Core (APK)。如果需要拉起升级引导界面,建议传入Activity类型参数替代Context类型。

Parameters

Parameter nameParameter desc
context上下文。
accessToken要清除的token。

Throws

Parameter nameParameter desc
HuaweiIdAuthException认证异常。
Method
public static void deleteAuthInfo(Activity activity, String accessToken) throws HuaweiIdAuthException

清除本地缓存。

说明:
当传入参数为非Activity类型时,调用deleteAuthInfo接口会发生异常,不会弹出UI交互界面提示用户处理。例如:当HMS Core (APK)不符合帐号服务的版本要求时,便会抛出“hms apk version is low”异常信息,此时需要手动升级HMS Core (APK)。如果需要拉起升级引导界面,建议传入Activity类型参数替代Context类型。。

Parameters

Parameter nameParameter desc
activityActivity。
accessToken要清除的token。

Throws

Parameter nameParameter desc
HuaweiIdAuthException认证异常。
Method
public static String requestUnionId(Activity activity, String huaweiAccountName) throws HuaweiIdAuthException

获取unionId。

说明:
当传入参数为非Activity类型时,调用requestUnionId接口会发生异常,不会弹出UI交互界面提示用户处理。例如:当HMS Core (APK)不符合帐号服务的版本要求时,便会抛出“hms apk version is low”异常信息,此时需要手动升级HMS Core (APK)。如果需要拉起升级引导界面,建议传入Activity类型参数替代Context类型。

Parameters

Parameter nameParameter desc
activityActivity。
huaweiAccountName华为帐号名。

Throws

Parameter nameParameter desc
HuaweiIdAuthException认证异常。

Return

typedesc
String获取到的unionId。
Method
public static String requestUnionId(Context context, String huaweiAccountName) throws HuaweiIdAuthException
获取unionId。
说明:
当传入参数为非Activity类型时,调用requestUnionId接口会发生异常,不会弹出UI交互界面提示用户处理。例如:当HMS Core (APK)不符合帐号服务的版本要求时,便会抛出“hms apk version is low”异常信息,此时需要手动升级HMS Core (APK)。如果需要拉起升级引导界面,建议传入Activity类型参数替代Context类型。

Parameters

Parameter nameParameter desc
context上下文。
huaweiAccountName华为帐号名。

Throws

Parameter nameParameter desc
HuaweiIdAuthException认证异常。

Return

typedesc
String获取到的unionId。
Method
public static String requestAccessToken(Context context, Account huaweiAccount, List<Scope> scopeList) throws HuaweiIdAuthException
获取token。
说明:
当传入参数为非Activity类型时,调用requestAccessToken接口会发生异常,不会弹出UI交互界面提示用户处理。例如:当HMS Core (APK)不符合帐号服务的版本要求时,便会抛出“hms apk version is low”异常信息,此时需要手动升级HMS Core (APK)。如果需要拉起升级引导界面,建议传入Activity类型参数替代Context类型。

Parameters

Parameter nameParameter desc
context上下文。
huaweiAccount要获取token的华为帐号。
scopeList华为帐号授权Scope。

Throws

Parameter nameParameter desc
HuaweiIdAuthException认证异常。

Return

typedesc
String获取到的token。
Method
public static String requestAccessToken(Activity activity, Account huaweiAccount, List<Scope> scopeList) throws HuaweiIdAuthException

获取token。

说明:
当传入参数为非Activity类型时,调用requestAccessToken接口会发生异常,不会弹出UI交互界面提示用户处理。例如:当HMS Core (APK)不符合帐号服务的版本要求时,便会抛出“hms apk version is low”异常信息,此时需要手动升级HMS Core (APK)。如果需要拉起升级引导界面,建议传入Activity类型参数替代Context类型。

Parameters

Parameter nameParameter desc
activityActivity。
huaweiAccount要获取token的华为帐号。
scopeList华为帐号授权Scope。

Throws

Parameter nameParameter desc
HuaweiIdAuthException认证异常。

Return

typedesc
String获取到的token。
Method
public static String requestAccessToken(Context context, String huaweiAccountName, List<Scope> scopeList) throws HuaweiIdAuthException

已废弃,建议使用requestAccessToken(Context context, Account huaweiAccount,  List<Scope> scopeList)代替。

说明:
当传入参数为非Activity类型时,调用requestAccessToken接口会发生异常,不会弹出UI交互界面提示用户处理。例如:当HMS Core (APK)不符合帐号服务的版本要求时,便会抛出“hms apk version is low”异常信息,此时需要手动升级HMS Core (APK)。如果需要拉起升级引导界面,建议传入Activity类型参数替代Context类型。

Parameters

Parameter nameParameter desc
context上下文。
huaweiAccountName华为帐号名。
scopeList华为帐号授权Scope。

Throws

Parameter nameParameter desc
HuaweiIdAuthException认证异常。

Return

typedesc
String获取到的token。
Method
public static String requestAccessToken(Activity activity, String huaweiAccountName, List<Scope> scopeList) throws HuaweiIdAuthException
已废弃,建议使用requestAccessToken(Activity activity, Account huaweiAccount,  List<Scope> scopeList)代替。
说明:
当传入参数为非Activity类型时,调用requestAccessToken接口会发生异常,不会弹出UI交互界面提示用户处理。例如:当HMS Core (APK)不符合帐号服务的版本要求时,便会抛出“hms apk version is low”异常信息,此时需要手动升级HMS Core (APK)。如果需要拉起升级引导界面,建议传入Activity类型参数替代Context类型。

Parameters

Parameter nameParameter desc
activityActivity。
huaweiAccountName华为帐号名。
scopeList华为帐号授权Scope。

Throws

Parameter nameParameter desc
HuaweiIdAuthException认证异常。

Return

typedesc
String获取到的token。
Method
public static String requestAccessToken(Context context, Account huaweiAccount, List<Scope> scopeList, Bundle extendInfo) throws HuaweiIdAuthException
获取token。
说明:
当传入参数为非Activity类型时,调用requestAccessToken接口会发生异常,不会弹出UI交互界面提示用户处理。例如:当HMS Core (APK)不符合帐号服务的版本要求时,便会抛出“hms apk version is low”异常信息,此时需要手动升级HMS Core (APK)。如果需要拉起升级引导界面,建议传入Activity类型参数替代Context类型。

Parameters

Parameter nameParameter desc
context上下文。
huaweiAccount要获取token的华为帐号。
scopeList华为帐号授权Scope。
extendInfo额外数据。

Throws

Parameter nameParameter desc
HuaweiIdAuthException认证异常。

Return

typedesc
String获取到的token。
Method
public static String requestAccessToken(Activity activity, Account huaweiAccount, List<Scope> scopeList, Bundle extendInfo) throws HuaweiIdAuthException
获取token。
说明:
当传入参数为非Activity类型时,调用requestAccessToken接口会发生异常,不会弹出UI交互界面提示用户处理。例如:当HMS Core (APK)不符合帐号服务的版本要求时,便会抛出“hms apk version is low”异常信息,此时需要手动升级HMS Core (APK)。如果需要拉起升级引导界面,建议传入Activity类型参数替代Context类型。

Parameters

Parameter nameParameter desc
activityActivity。
huaweiAccount要获取token的华为帐号。
scopeList华为帐号授权Scope。
extendInfo额外数据。

Throws

Parameter nameParameter desc
HuaweiIdAuthException认证异常。

Return

typedesc
String获取到的token。
Method
public static String requestAccessToken(Context context, String huaweiAccountName, List<Scope> scopeList, Bundle extendInfo) throws HuaweiIdAuthException

已废弃,建议使用requestAccessToken(Context context, Account huaweiAccount,  List<Scope> scopeList, Bundle extendInfo)代替。

说明:
当传入参数为非Activity类型时,调用requestAccessToken接口会发生异常,不会弹出UI交互界面提示用户处理。例如:当HMS Core (APK)不符合帐号服务的版本要求时,便会抛出“hms apk version is low”异常信息,此时需要手动升级HMS Core (APK)。如果需要拉起升级引导界面,建议传入Activity类型参数替代Context类型。

Parameters

Parameter nameParameter desc
context上下文。
huaweiAccountName华为帐号名。
scopeList华为帐号授权Scope。
extendInfo额外数据。

Throws

Parameter nameParameter desc
HuaweiIdAuthException认证异常。

Return

typedesc
String获取到的token。
Method
public static String requestAccessToken(Activity activity, String huaweiAccountName, List<Scope> scopeList, Bundle extendInfo) throws HuaweiIdAuthException
已废弃,建议使用requestAccessToken(Activity activity, Account huaweiAccount,  List<Scope> scopeList, Bundle extendInfo)代替。
说明:
当传入参数为非Activity类型时,调用requestAccessToken接口会发生异常,不会弹出UI交互界面提示用户处理。例如:当HMS Core (APK)不符合帐号服务的版本要求时,便会抛出“hms apk version is low”异常信息,此时需要手动升级HMS Core (APK)。如果需要拉起升级引导界面,建议传入Activity类型参数替代Context类型。

Parameters

Parameter nameParameter desc
activityActivity。
huaweiAccountName华为帐号名。
scopeList华为帐号授权Scope。
extendInfo额外数据。

Throws

Parameter nameParameter desc
HuaweiIdAuthException认证异常。

Return

typedesc
String获取到的token。