/// <summary> /// 拉起授权页、点一键登录取号以及授权页其他用户操作的回调 /// </summary> /// <param name="result"> json 格式的返回参数</param> public void onResult(string result) { owner.log("OneLoginPluginCallback onResult, result=" + result); // 反序列化时注意 operator 关键字 OLResult olResult = JsonUtility.FromJson <OLResult>(result.Replace("operator", "operator_type")); owner.log("OneLoginPluginCallback onResult, olResult=" + olResult); if (olResult.status == 200) { owner.log("一键登录取号成功: process_id=" + olResult.process_id + ", token=" + olResult.token + ", authcode=" + olResult.authcode + ", id_2_sign=" + olResult.app_id); // 取号成功后用以上四个参数请求服务端 check_phone 接口换取真实手机号,当前 demo 略 owner.checkPhone(olResult); } else { owner.toast("onResult:" + result); string errorCode = olResult.errorCode; if ("-20301".Equals(errorCode) || "-20302".Equals(errorCode)) { owner.log("用户点击返回键关闭了授权页面"); return; } else if ("-20303".Equals(errorCode)) { owner.log("用户点击切换账号"); } owner.olManager.Call("dismissAuthActivity"); } }
// 一键登录取号成功后通过服务端 check_phone 接口置换手机号 public void checkPhone(OLResult olResult) { log("checkPhoneThread start"); //OLResult olResult = obj as OLResult; olResult.id_2_sign = Constants.APP_ID_OL; string param = JsonUtility.ToJson(olResult, false); olManager.Call("requestPost", Constants.CHECK_PHONE_URL, param, 8000, new RequestPostCallback(this, true)); //olManager.Call("dismissAuthActivity"); }