bitly / bitly-api-python

python library to the bitly api
http://github.com/bitly/bitly-api-python
Other
244 stars 92 forks source link

INVALID_ARG_ACCESS_TOKEN on valid access token. #34

Closed abelsonlive closed 9 years ago

abelsonlive commented 9 years ago

I'm continually getting this error when I try to shorten a url. My code is as follows:

import bitly_api as bitly

bitly_api = bitly.Connection(access_token='R_fsjlkasdfsd')
bitly_api.shorten('http://example.com')

Which returns this traceback:

>>> bitly_api/bitly_api.py", line 87, in shorten
    data = self._call(self.host, 'v3/shorten', params, self.secret)
  File "/Users/brianabelson/.virtualenvs/newslynx/lib/python2.7/site-packages/bitly_api/bitly_api.py", line 789, in _call
    data.get('status_txt', 'UNKNOWN_ERROR'))
BitlyError: INVALID_ARG_ACCESS_TOKEN

I'm assuming it's not the library, but nothing seems to work (even repeatedly resetting my access token)

jehiah commented 9 years ago

The error your getting is because the value you are using is a legacy ApiKey not an Access Token. See http://dev.bitly.com/authentication.html for details on how to obtain an OAuth Access Token.

factorlive commented 5 years ago

Shortcut for anybody who wants to skip to read the doc.

As noted by jehiah, the easiest way is to refer to the doc, i.e.:

1.) type into your shell

curl -u "username:password" -X POST "https://api-ssl.bitly.com/oauth/access_token"

2.) replace that "R_.." depreciated token

3.) don't post tokens on a forum