ref |> 联调华为账号一键登录功能
Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
Showing
1 changed file
with
14 additions
and
4 deletions
| @@ -9,7 +9,7 @@ const TAG = "HuaweiOneKeyAuth" | @@ -9,7 +9,7 @@ const TAG = "HuaweiOneKeyAuth" | ||
| 9 | export default class HuaweiAuth { | 9 | export default class HuaweiAuth { |
| 10 | 10 | ||
| 11 | // 是否开启 | 11 | // 是否开启 |
| 12 | - static enable = false | 12 | + static enable = true |
| 13 | // 匿名手机号 | 13 | // 匿名手机号 |
| 14 | private _anonymousPhone?: string | 14 | private _anonymousPhone?: string |
| 15 | get anonymousPhone() { | 15 | get anonymousPhone() { |
| @@ -86,9 +86,19 @@ export default class HuaweiAuth { | @@ -86,9 +86,19 @@ export default class HuaweiAuth { | ||
| 86 | // 返回结果为 Authorization Code | 86 | // 返回结果为 Authorization Code |
| 87 | oneKeyLogin() : Promise<string> { | 87 | oneKeyLogin() : Promise<string> { |
| 88 | 88 | ||
| 89 | - let loginRequest = new authentication.HuaweiIDProvider().createLoginWithHuaweiIDRequest(); | ||
| 90 | - // 当用户未登录华为帐号时,是否强制拉起华为帐号登录界面 | ||
| 91 | - loginRequest.forceLogin = true; | 89 | + // let loginRequest = new authentication.HuaweiIDProvider().createLoginWithHuaweiIDRequest(); |
| 90 | + // // 当用户未登录华为帐号时,是否强制拉起华为帐号登录界面 | ||
| 91 | + // loginRequest.forceLogin = true; | ||
| 92 | + // loginRequest.state = util.generateRandomUUID(); | ||
| 93 | + | ||
| 94 | + // 创建授权请求,并设置参数 | ||
| 95 | + let loginRequest = new authentication.HuaweiIDProvider().createAuthorizationWithHuaweiIDRequest(); | ||
| 96 | + // 获取头像昵称需要传如下scope | ||
| 97 | + loginRequest.scopes = ['profile', 'phone']; | ||
| 98 | + // 若开发者需要进行服务端开发,则需传如下permission获取authorizationCode | ||
| 99 | + loginRequest.permissions = ['serviceauthcode']; | ||
| 100 | + // 用户是否需要登录授权,该值为true且用户未登录或未授权时,会拉起用户登录或授权页面 | ||
| 101 | + loginRequest.forceAuthorization = true; | ||
| 92 | loginRequest.state = util.generateRandomUUID(); | 102 | loginRequest.state = util.generateRandomUUID(); |
| 93 | 103 | ||
| 94 | return new Promise((resolve, fail) => { | 104 | return new Promise((resolve, fail) => { |
-
Please register or login to post a comment