oppo快应用开通账号服务获取openid记录

一、注册oppo账号

https://open.oppomobile.com

管理中心-> 快应用智慧服务-> 选择一个快应用-> 找到移动服务

《oppo快应用开通账号服务获取openid记录》
《oppo快应用开通账号服务获取openid记录》

根据 OPPO快应用帐号服务开启指南开通服务即可,其中回调地址可以随便写,可以使用 oppo的示例即可

《oppo快应用开通账号服务获取openid记录》

二、获取用户信息

开通账户服务之后我们就可以参考文档来获取用户信息了,但是这里还是拿不到用户信息的

  • 调用授权接口 account.authorize 返回的信息格式是这样的
{

  "accessToken": "token",
  "state": "state",
  "tokenType": "type",
  "scope": "scope",
  "expiresIn": ""
}

解决方法

加了官方群后无人解答,最后问了客服找到了答案

完整示例代码

onInit(){

account.authorize({
   type: 'token',
   redirectUri: 'https://baidu.com', // 跳转地址,可不填
   scope: 'scope.baseProfile',
   success: function ( data) {
      console.log( JSON.stringify(data))
     
      // 获取用户基本信息
     account.getProfile({
       token: data.accessToken,
       success: function ( data) {
         prompt.showToast({
           message: 'handling success:' + JSON.stringify(data),
           duration: 1
         })
       },
       fail: function ( data, code) {
         prompt.showToast({
           message: `getProfile handling fail, code = ${code}`,
           duration: 1
         })
       }
     })
   },
   fail: function ( data, code) {
     prompt.showToast({
       message: `authorize handling fail, code = ${code}`,
       duration: 1
     })
   }
 })
},

三、更多参考

    原文作者:a1322674015
    原文地址: http://blog.itpub.net/69946034/viewspace-2660712/
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞