This is my first foray into OAuth, so please be patient with me if I'm way off base, or going in an entirely wrong direction.
I want to write a script to pull information from basecamp 3, format it, and send it in an email. I already do this with basecamp 2 and it works fine. But basecamp 3 does not allow simple authentication. This is just a script that runs via cron once per week.
Most of the OAuth examples I've found require getting an authorization url, going to it in a browser, granting authorization, etc in order to get an access token. Please tell me there is an automated way! I can't let this become a manual process.
I tried the Backend Application Flow with requests-oauthlib (found here: https://requests-oauthlib.readthedocs.io/en/latest/oauth2_workflow.html#backend-application-flow)
I have tried their example pretty much straight up without luck:
from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session
ktclient_id = r'my-client-id'
ktclient_secret = r'my-client-secret'
ktredirect_uri = r'http://www.company.com/whatever'
client = BackendApplicationClient(client_id=ktclient_id)
oauth = OAuth2Session(client=client)
token = oauth.fetch_token(token_url=r'https://launchpad.37signals.com/authorization/token',
client_id=ktclient_id,
client_secret=ktclient_secret)
Here is the error that I get:
Traceback (most recent call last):
File "./get-token.py", line 20, in <module>
client_secret=ktclient_secret)
File "/home/mwilson/.local/lib/python2.7/site-packages/requests_oauthlib/oauth2_session.py", line 244, in fetch_token
self._client.parse_request_body_response(r.text, scope=self.scope)
File "/home/mwilson/.local/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 409, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/home/mwilson/.local/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 376, in parse_token_response
validate_token_parameters(params)
File "/home/mwilson/.local/lib/python2.7/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 386, in validate_token_parameters
raise MissingTokenError(description="Missing access token parameter.")
oauthlib.oauth2.rfc6749.errors.MissingTokenError: (missing_token) Missing access token parameter.
I've tried specifying the redirect_uri in the line
oauth = OAuth2Session(client=client, redirect_uri=ktredirect_uri)
And I get the same result. Anyone ever have any luck with this? What other parameter does basecamp 3 require?