当前位置: 首页 > wzjs >正文

湖北网站排名优化购买网站

湖北网站排名优化,购买网站,网站建设教程公司湖南岚鸿o k,做网站法人拍照背景1.获取 authorizationCode: 2.利用 authorizationCode 获取 accessToken:文档中心 3.获取手机:文档中心 4.获取昵称头像:文档中心 首先创建 request 若要获取手机号,scope必填 phone,permissions 必填 …

1.获取 authorizationCode:

2.利用 authorizationCode 获取 accessToken:文档中心

3.获取手机:文档中心

4.获取昵称头像:文档中心

首先创建 request

若要获取手机号,scope必填 phone,permissions 必填 serviceauthcode,否则第 3 步将无法返回预期的字段,第 3 步与第 4 步调用接口一致,报文返回结果根据 scope 进行返回

// 创建授权请求,并设置参数
const authRequest = new authentication.HuaweiIDProvider().createAuthorizationWithHuaweiIDRequest();
authRequest.scopes = ['phone']; // 元服务不支持profile,需传其他支持的scope。默认返回UnionID、OpenID
authRequest.permissions = ['serviceauthcode']; 
authRequest.forceAuthorization = true;
authRequest.state = util.generateRandomUUID(); // 建议使用generateRandomUUID生成state
authRequest.idTokenSignAlgorithm = authentication.IdTokenSignAlgorithm.PS256;

 若要获取昵称,头像,scope必填 phone,permissions 必填 serviceauthcode。

// 创建授权请求,并设置参数
const authRequest = new authentication.HuaweiIDProvider().createAuthorizationWithHuaweiIDRequest();
authRequest.scopes = ['profile']; // 元服务不支持profile,需传其他支持的scope。默认返回UnionID、OpenID
authRequest.permissions = ['serviceauthcode']; 
authRequest.forceAuthorization = true;
authRequest.state = util.generateRandomUUID(); // 建议使用generateRandomUUID生成state
authRequest.idTokenSignAlgorithm = authentication.IdTokenSignAlgorithm.PS256;

根据接口调用返回的 authorizationCode,去调用 RESET公共API:

https://account.cloud.huawei.com/rest.php?nsp_svc=GOpen.User.getInfo

接口文档: 文档中心

// 执行授权请求,并处理结果
try {const controller = new authentication.AuthenticationController(getContext(this));controller.executeRequest(authRequest, (error: BusinessError<Object>, data) => {if (error) {this.dealAllError(error);return;}const authorizationWithHuaweiIDResponse = data as authentication.AuthorizationWithHuaweiIDResponse;const state = authorizationWithHuaweiIDResponse.state;if (state && authRequest.state !== state) {hilog.error(0x0000, 'testTag', `Failed to authorize. The state is different, response state: ${state}`);return;}hilog.info(0x0000, 'testTag', 'Succeeded in authentication.');const authorizationWithHuaweiIDCredential = authorizationWithHuaweiIDResponse.data!;const avatarUri = authorizationWithHuaweiIDCredential.avatarUri; // 元服务不支持该字段const nickName = authorizationWithHuaweiIDCredential.nickName; // 元服务不支持该字段const idToken = authorizationWithHuaweiIDCredential.idToken;const openID = authorizationWithHuaweiIDCredential.openID;const unionID = authorizationWithHuaweiIDCredential.unionID;const code = authorizationWithHuaweiIDCredential.authorizationCode;// 开发者处理avatarUri, nickName, idToken, openID, unionID, code});
} catch (error) {this.dealAllError(error);
}// 错误处理
dealAllError(error: BusinessError<Object>): void {hilog.error(0x0000, 'testTag', `Failed to auth. Code: ${error.code}, message: ${error.message}`);
}

接口即可正常返回预期报文。

http://www.dtcms.com/wzjs/596615.html

相关文章:

  • 怎样进行网站推广广州建筑集团官网首页
  • 途牛 招聘 网站开发flash 网站 源码
  • 找网页模板的网站简单的手机网址大全
  • 如何做网站收徒弟网站深圳网页设计招聘信息
  • dw做网站背景图片设置中堂镇做网站
  • 哈尔滨铁路局建设网站鹰潭市住房和城乡建设局网站
  • 吕梁做网站的公司天津装修公司哪家口碑好些
  • 多媒体网站建设ueditor for wordpress
  • dede网站后台地址扫描幻灯网站源码
  • 泉州pc网站开发网站中高端建设
  • 上海网站建设怎么asp双语网站后台怎么用
  • 网站设计模板 psd手机主页网站哪个好用
  • 产品展示型网站建设网站上海备案查询系统
  • 网站营销seo品牌网站 响应式网站
  • 深圳市网站设计公司seo官网优化
  • 公司网站总感觉少点什么找什么人做wordpress 旅游预订
  • 学习php做毕设网站方向网站建设指导思想和目标
  • 网站建设对用户影响wordpress淘宝客程序
  • 南阳做个网站多少钱上海网站建设开发电话
  • 郑州做网站_郑州免费建站建设电子商务平台
  • 电子商务的建站流程火鸟门户系统优点
  • 用ps做三网站横幅基于asp的网站开发
  • 运营一个网站的成本动画制作专业学校排名
  • 网站建设实践报告心得网站开发 旅游
  • 衡水市住房和城乡建设局网站做企业网站到哪里找
  • 网站建设明细报价商贸网站
  • 做商务网站公司网站建设岗位工作范围
  • 免费做网站wxp114企业网站酷站
  • 企业免费建网站wordpress浏览量修改
  • 网站顶部flash潍坊网站建设费用