title: How to use redirect (url) method in a class library?
body: <p>I am trying to build a web site which uses survey monkey API methods to show data, for that  I am building a class library in which I will call one(only one from some controller) method which should do the oauth of the user.(I was successful with the 3 step process mentioned in the survey monkey website) but now I want to call only one method from the controller to a method in class library which will do the oauth of the user and sets the token which can later be used for API methods. My code is like this in the class library:</p>
  
  <pre><code>HttpContext.Current.Response.Redirect(urlToAuthorize);
  
  //what should be here (I should wait till the user gives credentials and authorize so that I can get the query string)
  
  string tempAuthCode = HttpContext.Current.Session["code"].ToString();
  if (!verifyRedirectedTempCode(tempAuthCode))
  {
      return "Not a valid Token";
  }
  else
  {
      try
      {
          var webRequest = GetWebRequestForHttpPostOfSurveyMonkeyToken(ApiKey,ClientSecret,tempAuthCode,RedirectUri,ClientId,GrantType,ContentType,WebRequestMethod);
          using (HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse())
          {
              string tokenJson = new StreamReader(response.GetResponseStream()).ReadToEnd();
              AccessToken accesstokenObj = JsonConvert.DeserializeObject&lt;AccessToken&gt;(tokenJson);
              return accesstokenObj.Token.ToString();
          }
      }
      catch
      {
          return null;
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>After redirecting its not waiting for the user to authorize.So,its not working exactly as I am thinking. How to wait till the User authorize and collect this query string? It should be done in class library itself. </p>