예제 #1
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);
 }
예제 #2
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;
        }
예제 #3
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);
 }