inspirehep/invenio

Asana API have been upgraded

Closed this issue · 2 comments

Looks like Asana has upgraded API and we are using an outdated request:
https://sentry.cern.ch/inspire-sentry/inspire/group/822376/

tsgit commented

https://asana.com/developers/feed/api-key-deprecation

asana deprecated api keys in January 2016
asana started rejecting api requests which were still using api key and basic auth in May 2017
we should now be using oauth or personal access tokens

I patched

$ diff /usr/lib/python2.6/site-packages/asana/asana.py /usr/lib/python2.6/site-packages/asana/asana.py-apikey 
6,7d5
< requests.packages.urllib3.disable_warnings()
< 
31c29
<     def __init__(self, btoken, debug=False):
---
>     def __init__(self, apikey, debug=False):
36c34,35
<         self.authheader = {'Authorization': 'Bearer ' + btoken}
---
>         self.apikey = apikey
>         self.bauth = self.get_basic_auth()
82c81
<         r = requests.get(target, headers=self.authheader)
---
>         r = requests.get(target, auth=(self.apikey, ""))
106c105
<         r = requests.delete(target, headers=self.authheader)
---
>         r = requests.delete(target, auth=(self.apikey, ""))
139c138
<             target, headers=self.authheader, data=data, files=files)
---
>             target, auth=(self.apikey, ""), data=data, files=files)
166c165
<         r = requests.put(target, headers=self.authheader, data=data)
---
>         r = requests.put(target, auth=(self.apikey, ""), data=data)

and replace CFG_ASANA_API_KEY with a personal token

OK I registered an API key for the inspire-admin@cern.ch account :)