0

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());
            }
philshem
  • 24,761
  • 8
  • 61
  • 127
user3324848
  • 181
  • 1
  • 4
  • 17

1 Answers1

1

The API key you have listed there is the API key for our sample API console - you need to use your own API key, which you can view on the developer portal after you sign in.

The reason you're getting the 'missing parameters' error is you are trying to add the list of parameters to your 'redirect_uri' parameter - they are then getting url encoded and being read as part of that parameter, rather than parameters in their own right.