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%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
HarmonyOS
2024-12-23 15:08:23
716浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
FengTianYa
分享
微博
QQ
微信
回复
2024-12-23 17:09:36
相关问题
HarmonyOS 华为登陆问题
903浏览 • 1回复 待解决
OpenIDUnionID的长度限制要求
2924浏览 • 1回复 待解决
登陆时如何注入cookie
1543浏览 • 1回复 待解决
ubuntu系统用ROOT用户登陆的方法
2957浏览 • 1回复 待解决
HarmonyOS 华为账号登录接口返回信息
1687浏览 • 1回复 待解决
DevEco Studio无法登陆 一直这个画面
11579浏览 • 2回复 已解决
网站如何记录上次登陆时间?
2637浏览 • 1回复 待解决
HarmonyOS 华为账号登录获取头像昵称
1042浏览 • 1回复 待解决
HarmonyOS 华为账号登录界面
752浏览 • 1回复 待解决
HarmonyOS 华为账号登录报错1001500001
3067浏览 • 2回复 待解决
HarmonyOS 华为账号登录问题咨询
970浏览 • 1回复 待解决
HarmonyOS 华为账号一键登录
1396浏览 • 1回复 待解决
UnionID在元服务应用间的关系
3030浏览 • 1回复 待解决
HarmonyOS 华为企业账号关联认证疑问
869浏览 • 1回复 待解决