skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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 a code 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:

    https://api.surveymonkey.net/oauth/authorize?client_id=<your_client_id>&response_type=code&redirect_uri=<your_redirect_uri>
    

    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:

    https://example.com/surveymonkey/oauth?code=<oauth_code>
    

    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:

    POST https://api.surveymonkey.net/oauth/token
    Content-Type: application/x-www-form-urlencoded
    
    client_secret=<your_secret> 
    &code=<auth_code_you_just_got> 
    &redirect_uri=<same_redirect_uri_as_before> 
    &grant_type=authorization_code
    

    You can then make API calls to SurveyMonkey by adding the header Authorization: bearer <access_token> to your API calls to api.surveymonkey.net/v3/* and you’re good to go.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search