Пример #1
0
        internal RestRequest CreateTokenRequest(QQConnectConfig config, string code, string state="")
        {
            var request = new RestRequest(Method.GET);
            if (!string.IsNullOrEmpty(state))
            {
                request.Resource = "oauth2.0/token?grant_type=authorization_code&client_id={appkey}&client_secret={appsecret}&code={code}&state={state}&redirect_uri={callbackurl}";
                request.AddParameter("state", state, ParameterType.UrlSegment);
            }
            else
            {
                request.Resource = "oauth2.0/token?grant_type=authorization_code&client_id={appkey}&client_secret={appsecret}&code={code}&redirect_uri={callbackurl}";

            } 
            request.AddParameter("appkey", config.GetAppKey(), ParameterType.UrlSegment);
            request.AddParameter("appsecret", config.GetAppSecret(), ParameterType.UrlSegment);
            request.AddParameter("code", code, ParameterType.UrlSegment);
            request.AddParameter("callbackurl", config.GetCallBackURI(), ParameterType.UrlSegment);
            return request;
        }
Пример #2
0
        public static void RegisterAuth()
        {
            // To let users of this site log in using their accounts from other sites such as Microsoft, Facebook, and Twitter,
            // you must update this site. For more information visit http://go.microsoft.com/fwlink/?LinkID=252166

            //OAuthWebSecurity.RegisterMicrosoftClient(
            //    clientId: "",
            //    clientSecret: "");

            //OAuthWebSecurity.RegisterTwitterClient(
            //    consumerKey: "",
            //    consumerSecret: "");

            //OAuthWebSecurity.RegisterFacebookClient(
            //    appId: "",
            //    appSecret: "");

            //OAuthWebSecurity.RegisterGoogleClient();
            var qqConfig=new QQConnectConfig();
            OAuthWebSecurity.RegisterClient(new TencentOAuthClient(
                qqConfig.GetAppKey(),
                qqConfig.GetAppSecret(),
                "Tencent"), "QQ", null);
        }