HarmonyOS 华为账号登陆没有返回openid和unionid

import { authentication, loginComponentManager, LoginWithHuaweiIDButton } from '@kit.AccountKit'
import { Logger } from '@ohos/base'
import { showToast } from '../../component/NiceToast'
import { BusinessError } from '@kit.BasicServicesKit'
import { util } from '@kit.ArkTS'

@Entry
@Component
struct LoginTestPage {
  private _loginController: loginComponentManager.LoginWithHuaweiIDButtonController =
    new loginComponentManager.LoginWithHuaweiIDButtonController().onClickLoginWithHuaweiIDButton((error: BusinessError,
      response: loginComponentManager.HuaweiIDCredential) => {
      showToast(`登录组件登录完成:${JSON.stringify(response)}`)
      Logger.WARN({
        msg: `登录组件登陆完成:${JSON.stringify(response)}`
      })
    })
  build() {
    Column() {
      LoginWithHuaweiIDButton({
        params: {
          style: loginComponentManager.Style.BUTTON_WHITE,
          loginType: loginComponentManager.LoginType.ID,
          borderRadius: 10
        },
        controller: this._loginController
      }).width("68%")
        .margin({
          top: 20
        })
        .height(50)
        .backgroundColor(Color.Red)

      Text("华为登录")
        .fontSize(15)
        .margin({
          top: 20
        })
        .padding({
          top: 10,
          bottom: 10
        })
        .textAlign(TextAlign.Center)
        .width("68%")
        .fontColor(Color.Black)
        .backgroundColor(Color.White)
        .borderRadius(10)
        .onClick(() => {
          //showToast("登录")
          try {
            const _apiLoginController: authentication.AuthenticationController =
              new authentication.AuthenticationController()
            const request = new authentication.HuaweiIDProvider().createLoginWithHuaweiIDRequest()
            // request.scopes = ['profile','openid']
            // request.permissions = ['idtoken']
            // request.forceAuthorization = true
            request.forceLogin = true
            request.state = util.generateRandomUUID()
            _apiLoginController.executeRequest(request, (error, data) => {
              if (error) {
                Logger.ERROR({
                  msg: `API登陆失败:${JSON.stringify(error)}`
                })
                showToast($r("app.string.login_error_formater", JSON.stringify(error)))
              } else {
                Logger.ERROR({
                  msg: `API登陆完成:${JSON.stringify(data)}`
                })
                let loginWithHuaweiIDResponse = data as authentication.LoginWithHuaweiIDResponse;
                showToast(`API登录完成:${JSON.stringify(loginWithHuaweiIDResponse)}`)
              }
            })
          } catch (e) {
            Logger.ERROR({
              msg: `API登陆异常:${JSON.stringify(e)}`
            })
            showToast($r("app.string.login_error_formater", JSON.stringify(e)))
          }
        })
    }
    .height('100%')
    .width('100%')
  }
}
HarmonyOS
2024-12-23 15:08:23
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
FengTianYa
分享
微博
QQ
微信
回复
2024-12-23 17:09:36
相关问题
HarmonyOS 华为登陆问题
1189浏览 • 1回复 待解决
OpenIDUnionID的长度限制要求
3219浏览 • 1回复 待解决
登陆时如何注入cookie
1740浏览 • 1回复 待解决
ubuntu系统用ROOT用户登陆的方法
3199浏览 • 1回复 待解决
HarmonyOS 华为账号登录接口返回信息
2008浏览 • 1回复 待解决
DevEco Studio无法登陆 一直这个画面
12087浏览 • 2回复 已解决
网站如何记录上次登陆时间?
2854浏览 • 1回复 待解决
HarmonyOS 华为账号登录获取头像昵称
1336浏览 • 1回复 待解决
HarmonyOS 华为账号登录界面
1004浏览 • 1回复 待解决
HarmonyOS 华为账号登录报错1001500001
3575浏览 • 2回复 待解决
HarmonyOS 华为账号登录问题咨询
1188浏览 • 1回复 待解决
HarmonyOS 华为账号一键登录
2156浏览 • 1回复 待解决
UnionID在元服务应用间的关系
3385浏览 • 1回复 待解决
HarmonyOS 华为企业账号关联认证疑问
1281浏览 • 1回复 待解决