I am trying to create a asp.net mvc 3 website which tracks the surveys which the user have created in the survey monkey . So, I am trying to access the API for which I need to pass through oauth of survey monkey.I am new to this concept.I have read about it.The problem for me is I am trying to get the access token by the 3 step process mentioned in survey moneky developer website , but I am not able to pass the parameters.I am getting the error, The authorization request failed:Missing required parameter(s) redirect_uri and/or client_id.I have seen the same question posted here but could'nt find a proper answer.
string surveymonkeypass = "http://localhost";
string client_id = "REDACTED";
string response_type = "code";
string api_key = "REDACTED";
string url = "https://api.surveymonkey.net/oauth/authorize";
string auth_dialog_uri = string.Format("redirect_uri={0}&client_id={1}&response_tpe={2}&api_key={3}", HttpUtility.UrlEncode(surveymonkeypass), HttpUtility.UrlEncode(client_id), HttpUtility.UrlEncode(response_type), HttpUtility.UrlEncode(api_key));
url = url + "?" + "redirect_uri=" + HttpUtility.UrlEncode(surveymonkeypass) + "&client_id=" + HttpUtility.UrlEncode(client_id) + "&response_tpe=" + HttpUtility.UrlEncode(response_type) + "&api_key=" + HttpUtility.UrlEncode(api_key);
System.Diagnostics.Process.Start(url);
The other block which I tried is and I am getting The authorization request failed:
string SM_API_BASE = "https://api.surveymonkey.net";
string AUTH_CODE_ENDPOINT = SM_API_BASE + "/oauth/authorize" + "?";
string auth_dialog_uri = string.Format("redirect_uri=http://localhost:57390/Survey/Create&client_id=REDACTED&response_type=code&api_key=uREDACTED");
WebRequest webRequest = WebRequest.Create(AUTH_CODE_ENDPOINT);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes(auth_dialog_uri);
webRequest.ContentLength = bytes.Length;
using (Stream outputStream = webRequest.GetRequestStream())
{
outputStream.Write(bytes, 0, bytes.Length);
StreamReader readStream = new StreamReader(outputStream, Encoding.UTF8);
ViewBag.Message = (readStream.ReadToEnd());
}