/// <summary> /// 授权通知 以便进行令牌获取 /// </summary> /// <param name="id"></param> /// <param name="code"></param> public void Notify(string id, string code) { if (authDic.ContainsKey(id)) { var auth = authDic[id].RefreshAuthModel(code); if (string.IsNullOrEmpty(auth.AccessToken)) { return; } AuthHandleEvent?.Invoke(auth); lock (lockObj) { if (dictionary.ContainsKey(id)) { dictionary[id] = auth; } else { dictionary.Add(id, auth); } } } }
/// <summary> /// 注册店铺应用认证事件 请使用AuthHandleEvent 监听事件返回结果 /// 请注意及时释放Event连接 /// </summary> /// <param name="info"></param> public void RegisterShopAuth(ShipInfo info) { if (dictionary.ContainsKey(info.Id.ToString())) { AuthHandleEvent?.Invoke(dictionary[info.Id.ToString()]); } else { if (info.Plat < 2) { authDic.Add(info.Id.ToString(), new AliAuthServer(info.Id.ToString(), info.AppKey, info.AppSecret)); } else if (info.Plat == 2) { authDic.Add(info.Id.ToString(), new JdAuthServer(info.Id.ToString(), info.AppKey, info.AppSecret)); } authDic[info.Id.ToString()]?.QueryAuthCode(); } }