I am fairly new to all the OAuth stuff. I did a Facebook OAuth a while back but found it very confusing, although I ultimately made it work.
I have a Rails/React app that I would like to plug into the Survey Monkey API. Specifically, I want to create surveys in the Survey Monkey dashboard, and then make GET
requests to get all that info, then use it to populate my own forms, bundle them up into a POST
and send em back to Survey Monkey.
Seems simple, but I don’t know where to begin! I created a Public App, which gave me my Client_ID
and Secret_ID
.
I guess my question is, literally first step here, where do I begin? Where am I supposed to put the client
and secret
id’s? Also, I am assuming that other than setting up something, I think, in the config
folder, I just make all my API calls in my controller and probably don’t need additional files or folder.
Again, I just need real barebones starting block type advice here. If someone wouldn’t mind, it would be a really big help. Thanks!
2
Answers
You should look to
omniauth
or a similar gem to help you all things oAuth. There is no existing strategy for Survey Monkey, but you can probably get a good start seeing how those strategies are implemented.Bonus points if you can extract an OmniAuth strategy for Survey Monkey.
I can’t speak for the rails part, but for OAuth with SurveyMonkey the instructions are available here.
Basically, with your client ID and client secret, you’ll also need to set a redirect uri (a route in your app, say
/surveymonkey/oauth
to send acode
to that you can use to exchange for an access token.So when you want to get access to a user’s SurveyMonkey account, you will somewhere in your app send them to:
This will show them the SurveyMonkey OAuth page for your app, when the user clicks “Authorize” we will send them back to your redirect URI that you set with the code, something like:
Your view pulls the code from the GET parameter then you can exchange that code for a long lived access token that you would store somewhere:
You can then make API calls to SurveyMonkey by adding the header
Authorization: bearer <access_token>
to your API calls toapi.surveymonkey.net/v3/*
and you’re good to go.