1

I am currently unable to figure out how to obtain my long-lived access token so I can create an API data feed from Survey Monkey to Alteryx.

Thus far I have been able to:

1) Go to the OAUTH page https ://api.surveymonkey.net/oauth/authorize?redirect_uri=https:// www.surveymonkey.com&client_id=[MY-CLIENT-ID]&response_type=code

2) Authenticate access (I am not a robot: reCAPTCHA)

3) Get the Authentication Response with the short-lived code https: //www. surveymonkey.com/home/?code=[CODE-FROM-RESPONSE]

4) Got stuck

From: https://developer.surveymonkey.com/docs/guides/oauth-guide/

To make the exchange, simply create a form-encoded ( Content-Type: application/x-www-form-urlencoded) HTTP POST request to https://api.surveymonkey.net/oauth/token?api_key=YOUR_API_KEY with the following encoded form fields: client_secret, code, redirect_uri and grant_type. The grant type must be set to "authorization_code".

This is not a "simply" for me, and would really appreciate the expression so I can enter that into my browser so I can retrieve my long-lived access token.

End goal is that I am using Alteryx to pull in the Survey Monkey data via API and creating a blended data set with additional system data. The combined data set will then feed a Tableau Dashboard. I'm sure it is a long-shot, but if anyone has an Alteryx workflow for Survey Monkey API that would solve all of my issues at once.

Thank you in advance for your insights/ guidance.

With gratitude, Drew

(Note- I added spaces to a few of the links, as I do not have 10 reputation points; yet).

2 Answers2

2

There is an example cURL request at the side of the docs here. You need to make a POST request to /oauth/token. It'll look something like this:

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'code=<code>&client_id=<client_id>&client_secret=<client_secret>&redirect_uri=<redirect_uri>&grant_type=authorization_code' "https://api.surveymonkey.net/oauth/token"

Filling in the values in <>. Or in Python, something like this should work:

import requests

url = "https://api.surveymonkey.net/oauth/token"

payload = {
    "code": "<code>",
    "client_id": "<client_id>",
    "client_secret": "<client_secret>",
    "redirect_uri": "<redirect_uri>",
    "grant_type": "authorization_code"
}

headers = {
    'content-type': "application/x-www-form-urlencoded"
}

response = requests.request("POST", url, data=payload, headers=headers)

I'm pretty sure the requests library will automatically convert the body to the right type, but if not payload just looks like URL params:

payload = "code=<code>&client_id=<client_id>&client_secret=<client_secret>&redirect_uri=<redirect_uri>&grant_type=authorization_code"

Essentially though, you just need to make a POST request to /oauth/token with the payload provided above (code, client_id, client_secret, redirect_uri, and grant_type). The main confusing part is you can't send in a JSON body, it has to be a form body that looks like my example above.

Hope that helps.

General Kandalaft
  • 2,215
  • 2
  • 18
  • 25
1

You should be able to take the response that General Kandalaft has provided and enter each of those into the Download Tool in Alteryx. Create a field for each of client id, client secret, code, redirect_uri & grant_type and then tick those fields on the Payload Tab.

Set the HTTP Action to POST on the same tab.

There are also some examples of Oauth processes on the Alteryx Community and Gallery.

In general, when converting cURL requests to the Download Tool, -d/-F will be payload tab and -H of course will be Headers tab. form encoded etc is normally correct already and only needs to be added/changed very occasionally.

As another note, if you can't figure out the conversion of a cURL request or it's more complicated (i.e. attaching a PEM file to the call), you will find a copy of cURL in your Alteryx install directory and you can use the Run Command Tool to run that.

Kane

KaneG
  • 146
  • 4