Pregunta

So I've tried this code to pass my id, key and other info to the website to start Oauth approval but it isn't getting them. I'm fairly new to c# and Oauth so im not sure what to do.

 string url = "https://api.surveymonkey.net/oauth/authorize"; 
 string surveymonkeyPass =  HttpUtility.UrlEncode("redirect_uri=notsureyet.com");
 url = url + "?" + suverymonkeyPass;
 System.Diagnostics.Process.Start(url);

How can i send my id api_key response type and redirect_uri?

¿Fue útil?

Solución

It would seem you need to pass a client id also as I receive the following message when using your url:

SurveyMonkey

The authorization request failed: Missing required parameter(s) redirect_uri and/or client_id.

When adding a random client id (e.g. https://api.surveymonkey.net/oauth/authorize?redirect_uri=notsureyet.com&client_id=xx ) the following message is displayed:

SurveyMonkey

The authorization request failed: Invalid client_id "xx".

Otros consejos

localhost will work if you have a service running on your local machine listentening on port 80 ready to receive the redirect from SurveyMonkey's oAuth page. The browser window you're opening with System.Diagnostics.Process.Start(url) will prompt you for your SurveyMonkey username and password and then redirect you to the redirect_uri you specified with with a parameter "code".

Your service on port 80 needs to receive this request, parse the code parameter and then exchange the code for an access token by making a request to https://api.surveymonkey.net/oauth/token with your code, api_key, redirect_uri, grant_type and client_secret as parameters. If everything passes muster, you'll get a json response with access_token as a key and the the access token as it's value.

If you're not running a local service, you would need to direct to a service hosted elsewhere which does the same thing.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top