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); }