philnash / bitly

🗜 A Ruby wrapper for the bit.ly API
https://rubygems.org/gems/bitly
MIT License
451 stars 139 forks source link

INVALID_APIKEY with Generic Access Token #50

Closed philgyford closed 8 years ago

philgyford commented 11 years ago

Sorry, I must be doing something wrong, as I'm following the example but when trying to shorten a URL I keep getting an error. I do this:

Bitly.use_api_version_3

Bitly.configure do |config|
    config.api_version = 3
    config.login = 'mylogin'
    config.api_key = 'myGenericAccessToken'
end

bitly_client = Bitly.client
#<Bitly::V3::Client:0x007fc87589bdc8 @default_query_opts={:login=>"mylogin", :apiKey=>"myGenericAccessToken"}> 

u = bitly_client.shorten("http://www.example.org")

That gets me:

BitlyError: INVALID_APIKEY - '500'
from /Users/phil/.rvm/gems/ruby-1.9.3-p392/gems/bitly-0.9.0/lib/bitly/v3/client.rb:141:in `get'
from /Users/phil/.rvm/gems/ruby-1.9.3-p392/gems/bitly-0.9.0/lib/bitly/v3/client.rb:41:in `shorten'
from (irb):17
from /Users/phil/.rvm/rubies/ruby-1.9.3-p392/bin/irb:16:in `<main>'

Anything obvious I've done wrong?

ttringas commented 11 years ago

Had this same problem, you need your API key, which is different. Head to https://bitly.com/a/your_api_key to get it.

philnash commented 10 years ago

Hi @philgyford,

Sorry for the huge delay on this. Before recently, the generic API key method didn't work using the gem. However, with version 0.10.0 you can configure the gem like so:

Bitly.configure do |config|
  config.api_version = 3
  config.access_token = "MYGENERICACCESSTOKEN"
end

and it will authenticate with your access token and not your login and password.

jianbo commented 9 years ago

I am getting BitlyError: INVALID_ARG_ACCESS_TOKEN - '500' using latest 0.10.3, any idea?

vincentcordel commented 9 years ago

Don't use the deprecated API key, use oAuth on Bitly settings.

sachinswagh-opcito commented 6 years ago

@jianbo : How did you solve it? I am facing same issue that is INVALID_ARG_ACCESS_TOKEN - '500' with 1.1.1 also.

sachinswagh-opcito commented 6 years ago

@philnash : I am facing INVALID_ARG_ACCESS_TOKEN - '500' with bitly 1.1.1 also. Would you please help?

philnash commented 6 years ago

Can you share the code you are using that is generating that error? It looks like an error coming from the Bitly API rather than the gem, though is probably how you are using it. I can't debug without an idea of what you're doing though.