connecting from the backend to fetch all surveys in my account

耗尽温柔 提交于 2019-12-14 04:02:37

问题


I need to do all my actions on the back-end, no browser.
In the documentation I see I need the following values to get the Authorization: bearer ???????? value.

curl -i -X POST https://api.surveymonkey.net/oauth/token -d \
"client_secret=YOUR_CLIENT_SECRET \
&code=AUTH_CODE \
&redirect_uri=YOUR_REDIRECT_URI \
&client_id=YOUR_CLIENT_ID \
&grant_type=authorization_code"

I am not building an app, I just want to connect to my account to fetch all surveys.
Where do I get the values for:
YOUR_CLIENT_SECRET
AUTH_CODE
YOUR_CLIENT_ID

What do I put in YOUR_REDIRECT_URI as there is no such thing in back-end actions.


回答1:


You always need an application created in order to get an access token. There is an undocumented method for backend API access (for the app owner) using the grant type client_credentials.

curl -X POST \
  https://api.surveymonkey.net/oauth/token \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'client_secret=<secret>&client_id=<client_id>&grant_type=client_credentials'

This should work for getting access to your own account.

With regards to the app, you can leave the redirect URI alone. Note if you go to the settings page of your app, it also provides you with an access token to use, but I would advise using the above flow as a way to handle tokens being revoked or expired in the future.



来源:https://stackoverflow.com/questions/46897845/connecting-from-the-backend-to-fetch-all-surveys-in-my-account

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!