当前位置: 首页 > 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/242501.html

相关文章:

  • 基于PHP网站开发的管理系统设计与开发百度收录比较好的网站
  • word做招聘网站建立网站费用大概需要多少钱
  • 外贸网站怎么做seo优化自己建网站怎样建
  • 桐柏网站麒麟seo软件
  • 小零件加工在家做惠州抖音seo策划
  • 新建网站如何推广网络app推广是什么工作
  • 婚恋网站建设技巧家居seo整站优化方案
  • 原阳网站建设哪家好企业网站运营推广
  • 长春网站建设制作seo的作用主要有
  • 响应式 网站 设计软件中和seo公司
  • 专门做图片的网站cmsseo研究中心怎么样
  • 大学网站建设成都网站优化排名
  • 怎么做钓鱼网站搜狗推广管家
  • 卧龙区2015网站建设价格seo工程师
  • 济南网站哪家做的好广告投放网站
  • 制作公众号的软件谷歌seo关键词排名优化
  • 网站设计在线培训机构网络营销方案例文
  • 河北建设委员会网站首页宁波seo网络推广定制
  • asp做网站缺点软文广告成功案例
  • 个人网站建设一般流程网络营销的手段有哪些
  • 嘉兴百度网站推广网络搭建教程
  • 福州网站大全百度官网下载安装到桌面上
  • 北京手机网站开发费用武汉seo哪家好
  • 谷歌网站推广排名工具石家庄网络推广
  • 惠州专门做网站360搜索指数
  • 做网站域名 空间新手怎么做网页
  • 网站的规划与建设_按时间顺序可以分为哪等五个阶段网络seo培训
  • 做软件与做网站建设有什么区别网络营销工具平台
  • 商城展示网站建设住房和城乡建设部官网
  • 克旗网站制作5229998济南全网推广