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

网站建设与维护的选择题editplus怎么创网站

网站建设与维护的选择题,editplus怎么创网站,网站建设的完整流程图,访问wordpress数据库场景介绍 如应用需要完善用户头像昵称信息#xff0c;可使用Account Kit提供的头像昵称授权能力#xff0c;用户允许应用获取头像昵称后#xff0c;可快速完成个人信息填写。以下只针对Account kit提供的头像昵称授权能力进行介绍#xff0c;若要获取头像还可通过场景化控…场景介绍 如应用需要完善用户头像昵称信息可使用Account Kit提供的头像昵称授权能力用户允许应用获取头像昵称后可快速完成个人信息填写。以下只针对Account kit提供的头像昵称授权能力进行介绍若要获取头像还可通过场景化控件选择头像Button进行获取。 业务流程 流程说明 应用传对应scope调用授权API请求获取用户头像昵称。如用户已给应用授权则开发者能直接获取用户头像昵称、UnionID、OpenID。如用户未授权则授权请求会拉起授权页面在用户确认授权后开发者能获取到用户头像昵称、UnionID、OpenID。获取到头像信息开发者可以下载该url使用该头像。 接口说明 获取头像昵称关键接口如下表所示具体API说明详见API参考。 接口名 描述 createAuthorizationWithHuaweiIDRequest(): AuthorizationWithHuaweiIDRequest 获取授权接口通过AuthorizationWithHuaweiIDRequest传入头像昵称的scopeprofile及Authorization Code的permissionserviceauthcode即可在授权结果中获取到用户头像昵称、UnionID、OpenID和Authorization Code。 constructor(context?: common.Context) 创建授权请求Controller。 executeRequest(request: AuthenticationRequest): PromiseAuthenticationResponse 通过Promise方式执行授权操作。 头像昵称可从AuthenticationResponse的子类AuthorizationWithHuaweiIDResponse中解析具体解析方法请参考客户端开发的示例代码。 注意 1.上述接口需在页面或自定义组件生命周期内调用。 2.未设置昵称默认返回华为账号绑定的匿名手机号/邮箱。 开发前提 在进行代码开发前请先确认您已完成配置Client ID工作。该场景无需申请scope权限。 开发步骤 客户端开发 导入authentication模块及相关公共模块。 import { authentication } from kit.AccountKit;import { hilog } from kit.PerformanceAnalysisKit;import { util } from kit.ArkTS;import { BusinessError } from kit.BasicServicesKit;创建授权请求并设置参数。 // 创建授权请求并设置参数const authRequest new authentication.HuaweiIDProvider().createAuthorizationWithHuaweiIDRequest();// 获取头像昵称需要传如下scopeauthRequest.scopes [profile];// 若开发者需要进行服务端开发则需传如下permission获取authorizationCodeauthRequest.permissions [serviceauthcode];// 用户是否需要登录授权该值为true且用户未登录或未授权时会拉起用户登录或授权页面authRequest.forceAuthorization true;// 用于防跨站点请求伪造authRequest.state util.generateRandomUUID();调用AuthenticationController对象的executeRequest方法执行授权请求并处理授权结果从授权结果中解析出头像昵称、UnionID、OpenID和Authorization Code。 // 执行授权请求try {const controller new authentication.AuthenticationController(getContext(this));controller.executeRequest(authRequest).then((data) {const authorizationWithHuaweiIDResponse data as authentication.AuthorizationWithHuaweiIDResponse;const state authorizationWithHuaweiIDResponse.state;if (state ! undefined 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 unionID authorizationWithHuaweiIDCredential.unionID;const openID authorizationWithHuaweiIDCredential.openID;const authorizationCode authorizationWithHuaweiIDCredential.authorizationCode;// 开发者处理avatarUri, nickName, unionIDopenIDauthorizationCode}).catch((err: BusinessError) {this.dealAllError(err);});} catch (error) {this.dealAllError(error);}// 错误处理dealAllError(error: BusinessError): void {hilog.error(0x0000, testTag, Failed to auth. Code: ${error.code}, message: ${error.message});} 服务端开发可选 开发者根据业务需要选择是否进行服务端开发。 应用服务器使用Client ID、Client Secret、Authorization Code调用获取用户级凭证的接口向华为账号服务器请求获取Access Token、Refresh Token。使用Access Token调用获取用户信息接口获取用户信息从用户信息中获取用户头像昵称。 Access Token过期处理 由于Access Token的有效期仅为60分钟当Access Token失效或者即将失效时可通过REST API错误码判断可以使用Refresh Token有效期180天通过刷新凭证向华为账号服务器请求获取新的Access Token。 说明 当Access Token失效时若您不使用Refresh Token向账号服务器请求获取新的Access Token账号的授权信息将会失效导致使用Access Token的功能都会失败。当Access Token非正常失效如修改密码、退出账号、删除设备时业务可重新登录授权获取Authorization Code向账号服务器请求获取新的Access Token。Refresh Token过期处理 由于Refresh Token的有效期为180天当Refresh Token失效后可通过REST API错误码判断应用服务器端需要通知客户端重新调用授权接口请求用户重新授权。
http://www.hkea.cn/news/14340411/

相关文章:

  • 查询价格的网站广州网站制作培训
  • 网站改版设计思路郑州网站设计
  • 做杂志的网站有哪些内容莱芜金点子电子版最新招聘信息
  • 简单好看个人主页网站模板专业团队介绍文案
  • 网站建设图片怎么切大连三川建设集团
  • 在那个网站找模具做图片在线转外链
  • 网站建设厌倦西平县住房和城乡建设局网站
  • 跑步机 东莞网站建设网站联系方式设计
  • 螺旋钢管网站建设网站建设 标书
  • 零起飞网站建设工作室seo推广怎么样
  • 苏州优秀网站设计做网站页面视频教学
  • 摄影师作品网站一个网站做无限关键词
  • 网站后台 清理缓存WordPress置顶不生效
  • 可以下载源程序的网站frontpage做网站教程
  • 做网站小程序做一网站要什么时候开始
  • 网站前端设计外包公司地图位置链接怎么做
  • 建站行业发展前景wordpress图片上传慢
  • 无忧主机建站的过程深圳做微商网站的公司
  • 网站建站推广上海市工程建设信息网
  • 免费网站平台推荐有那种网站么
  • 腾讯快速建站平台如何注册一个免费网站
  • 江苏建设标准网站徐州招聘网
  • 400网站建设推广个人外贸网站制作
  • 网站建设的标语2017网站seo如何做
  • 网站文章内容一键排版功能怎么做网站盈利
  • 成都网站seo诊断html做网站的设计
  • 找苏州网站建设wordpress商店如何添加商品
  • 网站运维平台建设原则旅游网站建设策划
  • 传媒公司做网站条件长宁长沙网站建设
  • 深圳网站建设ucreator合肥网站建设公司 推荐