コード例 #1
0
        public ActionResult GotoOAuth(int shopId)
        {
            if (shopId <= 0)
            {
                throw new ArgumentNullException("shopId");
            }
            CheckShopActor(shopId, ShopActorType.超级管理员);
            //确认当前shopId是否已经绑定了小程序
            var model = db.Query <ShopWechatOpenAuthorizer>()
                        .Where(m => !m.IsDel)
                        .Where(m => m.ShopId == shopId)
                        .FirstOrDefault();

            if (model != null)
            {
                throw new Exception("当前店铺绑定的小程序已经存在");
            }
            //获取预授权码

            //var preAuthCode = ComponentContainer.TryGetPreAuthCode(wechatOpenOptions.AppId, wechatOpenOptions.AppSecret, true);\
            string componentAccessToken = ZRui.Web.BLL.AuthorizerHelper.GetComponentAccessToken();

            var log         = BLL.DbContextFactory.LogDbContext;
            var preAuthCode = ComponentApi.GetPreAuthCode(wechatOpenOptions.AppId, componentAccessToken, 0x2710).pre_auth_code;

            var callbackUrl = $"http://manager.91huichihuihe.com/ShopWechatOpenOAuth/OAuthCallback?shopId={shopId}";//成功回调地址
            var url         = ComponentApi.GetComponentLoginPageUrl(wechatOpenOptions.AppId, preAuthCode, callbackUrl);

            return(Redirect(url));
        }
コード例 #2
0
        /// <summary>
        /// 发起授权页的体验URL
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> OAuth()
        {
            //获取预授权码
            var preAuthCode = await ComponentContainer.TryGetPreAuthCodeAsync(component_AppId, component_Secret, true);

            var callbackUrl = "http://sdk.weixin.senparc.com/OpenOAuth/OpenOAuthCallback";//成功回调地址
            var url         = ComponentApi.GetComponentLoginPageUrl(component_AppId, preAuthCode, callbackUrl);

            return(Redirect(url));
        }
コード例 #3
0
        /// <summary>
        /// 发起到微信公众号授权
        /// </summary>
        /// <returns></returns>
        public ActionResult OAuth()
        {
            //获取预授权码
            var preAuthCode = ComponentContainer.TryGetPreAuthCode(component_AppId, component_Secret, true);

            var callbackUrl = "http://wx.wftx666.com/Open/OAuthCallback";//成功回调地址
            var url         = ComponentApi.GetComponentLoginPageUrl(component_AppId, preAuthCode, callbackUrl);

            return(Redirect(url));
        }
コード例 #4
0
ファイル: OpenController.cs プロジェクト: qilabi/airshowapp
        /// <summary>
        /// 发起授权页的体验URL
        /// </summary>
        /// <returns></returns>
        public ActionResult OAuth()
        {
            //获取预授权码
            var preAuthCode = ComponentContainer.TryGetPreAuthCode(component_AppId, component_Secret, true);

            var callbackUrl = "http://senparcweixinmpsample.azurewebsites.net/Open/OpenOAuthCallback";//成功回调地址
            var url         = ComponentApi.GetComponentLoginPageUrl(component_AppId, preAuthCode, callbackUrl);

            return(Redirect(url));
        }
コード例 #5
0
        /// <summary>
        /// 发起授权页的体验URL
        /// </summary>
        /// <returns></returns>
        public ActionResult OAuth(string Id)
        {
            //获取预授权码
            var preAuthCode  = ComponentContainer.TryGetPreAuthCode(component_AppId, component_Secret);
            var openOAuthUrl = !string.IsNullOrEmpty(WebConfigurationManager.AppSettings["openOAuthUrl"]) ? WebConfigurationManager.AppSettings["openOAuthUrl"] : "http://open.chainclouds.com";
            var callbackUrl  = openOAuthUrl + "/OpenOAuth/OpenOAuthCallback?clientid=" + Id;//成功回调地址
            var url          = ComponentApi.GetComponentLoginPageUrl(component_AppId, preAuthCode, callbackUrl);

            return(Redirect(url));
        }
コード例 #6
0
        /// <summary>
        /// 发起授权页的体验URL
        /// </summary>
        /// <returns></returns>
        public ActionResult OAuth()
        {
            //获取预授权码
            var preAuthCode = ComponentContainer.TryGetPreAuthCode(options.AppId, options.AppSecret, true);

            var callbackUrl = "http://admin.91huichihuihe.com/WechatOpenOAuth/OpenOAuthCallback";//成功回调地址
            var url         = ComponentApi.GetComponentLoginPageUrl(options.AppId, preAuthCode, callbackUrl);

            return(Redirect(url));
        }