Esempio n. 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;
        }
Esempio n. 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);
        }
Esempio n. 3
0
 /// <summary>
 /// 用于用户已经完成授权后,将OAuthToken持久化保存后,使用这个函数从持久化介质中获取到的
 /// OAuthToken,进行后续的API调用。
 /// </summary>
 /// <param name="oAuthToken"></param>
 public QzoneContext(OAuthToken oAuthToken)
 {
     this.oAuthToken = oAuthToken;
     this.config = new QQConnectConfig();
     this.restApi = new RestApi(this);
 }
Esempio n. 4
0
 /// <summary>
 /// 用于用户接受授权后使用Authorization Code进行上下文设置
 /// </summary>
 /// <param name="authVericode">Authorization Code(注意此code会在10分钟内过期)</param>
 public QzoneContext(string authVericode)
 {
     this.oAuthVericode = authVericode;
     this.config = new QQConnectConfig();
     this.restApi = new RestApi(this);
 }