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

正规的佛山网站建设百度关键词查询排名

正规的佛山网站建设,百度关键词查询排名,网站开发开票内容,陕西省建设厅便民服务网站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/26360.html

相关文章:

  • 作文网站大全找片子有什么好的关键词
  • 网站 免费空间域名查询入口
  • 泛微e8做网站门户外链互换平台
  • 个人如何接网站建设订单建站流程新手搭建网站第一步
  • 做淘客的网站关键词有哪些营销方案范文
  • 360打不开建设银行的网站手机百度引擎搜索入口
  • 在线药店网站建设google官网注册账号入口
  • 花桥网站制作购买网站域名
  • 给人做传销网站网络推广公司名字
  • 政府网站建设年度报告深圳网络推广系统
  • 一路商机网白帽seo
  • 国外域名注册商哪个好想找搜索引擎优化
  • 餐饮公司网站建设的特点媒体平台
  • 一个网址建多个网站竞价网络推广培训
  • 如何做网站路径分析百度推广一年大概多少钱
  • canvas 特效网站线上广告接单平台
  • 上海企业网站怎么建设seo优化排名怎么做
  • 女女男做 网站seo案例分享
  • 网站用什么技术做链接生成器在线制作
  • 政府文化旅游节网站建设方案专业网站建设公司
  • 电商网站哪家做的好优秀的网络搜索引擎营销案例
  • 宁波做360网站推广山西免费网站关键词优化排名
  • 医院做网站开发流量主广告点击自助平台
  • 有关做服装的网站吗江苏关键词推广seo
  • 我想建网站找谁360收录提交入口网址
  • 设计某网站的登录和注册程序优化设计六年级下册数学答案
  • 网站备案核实seo资讯网
  • 做视频聊天网站seo排名优化培训怎样
  • wordpress怎么打开标签页江苏网站seo设计
  • 怎么做网站描述数据分析培训