I'm trying to access Gravity Forms entry data via their REST API v2 using Python, but can't figure out how to properly authenticate. Should I use basic authentication or OAuth1? I've never successfully used either so example code would be most helpful.
I've tried basic authentication which seems to be the default for the requests
module.
import requests
url = 'https://<INSERT DOMAIN HERE>/wp-json/gf/v2/entries'
auth = (<CONSUMER KEY>, <CONSUMER SECRET>)
r = requests.get(url, auth=auth)
print(r.status_code)
When basic auth didn't work, I also tried OAuth1 using requests_oathlib
and this post as a guideline, but I can't get that to work either. I'm not sure what the different keys/tokens/secrets are or how to get them. I have a "consumer key" and a "consumer secret" from the Gravity Forms REST API section of the WordPress dashboard, but that's it.
import requests
from requests_oauthlib import OAuth1
url = 'https://<INSERT DOMAIN HERE>/wp-json/gf/v2/entries'
auth = OAuth1('YOUR_APP_KEY', 'YOUR_APP_SECRET', 'USER_OAUTH_TOKEN', 'USER_OAUTH_TOKEN_SECRET')
r = requests.get(url, auth=auth)
print(r.status_code)
I've also tried following the docs for requests_oauthlib
here, but I'm not sure which urls to use where or which path to take (session vs helper).
Gravity Forms REST API documentation says that basic authentication is acceptable as long as requests are sent using HTTPS whereas HTTP requests must use OAuth1.0a. I can't get either to work. However, I know I'm close because I can get the Postman application to work using the "Consumer Key" and "Consumer Secret" with OAuth1 and a HMAC-SHA1 "Signature Method."
I'm expecting a 200 response status code, but no matter what type of authentication I use, I keep getting a 401 response status code.