Ruby/ClientError: user does not have access to word list

22 views
Skip to first unread message

Marilyn Roxie

unread,
Feb 24, 2018, 5:20:42 PM2/24/18
to Wordnik API
Hello!

I am new to using APIs and Ruby, so chances are there is something very basic I am missing. I am trying to get words from a word list that I own, however I am getting "ClientError: user does not have access to word list". I have put my correct username and password, so I'm not sure what is going on. I am thinking there is something about auth tokens that may be involved. Any help would be much appreciated. Thank you.

irb(main):001:0> %w(rubygems wordnik).each {|lib| require lib}

=> ["rubygems", "wordnik"]

irb(main):002:0> Wordnik.configure do |config|

irb(main):003:1* config.api_key = 'myapikey'

irb(main):004:1> config.username =

irb(main):005:1* 'username'

irb(main):006:1> config.password =

irb(main):007:1* 'password'

irb(main):008:1> end

=> ["account", "analytics", "corpus", "document", "feeds", "health", "partner", "partners", "suggest", "system", "tag", "user", "users", "word", "wordList", "wordLists", "words"]

irb(main):009:0> Wordnik.words.get_word_list_words('23456')

D, [2018-02-24T22:14:19.543421 #33135] DEBUG -- : 

  GET http://api.wordnik.com/v4/wordList.json/23456/words

  body: {}



ClientError: user does not have access to word list 630014

from /Library/Ruby/Gems/2.3.0/gems/wordnik-4.12/lib/wordnik/response.rb:28:in `catch_errors'

from /Library/Ruby/Gems/2.3.0/gems/wordnik-4.12/lib/wordnik/response.rb:18:in `initialize'

from /Library/Ruby/Gems/2.3.0/gems/wordnik-4.12/lib/wordnik/request.rb:181:in `new'

from /Library/Ruby/Gems/2.3.0/gems/wordnik-4.12/lib/wordnik/request.rb:181:in `make'

from /Library/Ruby/Gems/2.3.0/gems/wordnik-4.12/lib/wordnik/request.rb:185:in `response'

from /Library/Ruby/Gems/2.3.0/gems/wordnik-4.12/lib/wordnik/resource_modules/word_list.rb:138:in `get_word_list_words'

from (irb):9

from /usr/bin/irb:11:in `<main>'

irb(main):010:0> 

Marilyn Roxie

unread,
Feb 24, 2018, 5:24:22 PM2/24/18
to Wordnik API
I should add, when I visit http://api.wordnik.com:80/v4/account.json/authenticate/$username?password=$password&api_key=$yourkey  substituting the variables for my own information, I get {"message": "unauthorized", "type": "error"} in return.

Erin McKean

unread,
Feb 24, 2018, 5:34:19 PM2/24/18
to Wordnik API
Hmm. That's the API you need. Can you double-check your values? 


Unfortunately this is a hard one to help with as we don't like to ask you for your password, but if you want to email us at api...@wordnik.com directly we are happy to help further!

Yours,

Erin

Marilyn Roxie

unread,
Feb 24, 2018, 5:52:14 PM2/24/18
to Wordnik API
Hi Erin,

Thanks for your reply. Okay this time I got a token, not sure why it didn't work before. Where would I then indicate the token in Ruby so I can get words from my wordlist?

Erin McKean

unread,
Feb 24, 2018, 5:54:54 PM2/24/18
to wordn...@googlegroups.com
I haven't used the RubyGem in a while -- can you try adding
config.auth_token with the token value and seeing if that
automagically takes care of it?

If not, write me back. :) I'll be around a little longer today, and
can take another look tomorrow.

Do note that the token will expire periodically, and you'll have to
re-request it.

Thanks for using our API!

Yours,

Erin
> --
> You received this message because you are subscribed to the Google Groups
> "Wordnik API" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to wordnik-api...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Marilyn Roxie

unread,
Feb 24, 2018, 6:07:36 PM2/24/18
to Wordnik API
Just tried this out, Erin - unfortunately the result is the same. I've refreshed to try a new token, and still did not have access. No hurries - let me know if you have any other ideas when you get a chance. Thanks very much. ~Marilyn

irb(main):001:0> %w(rubygems wordnik).each {|lib| require lib}
=> ["rubygems", "wordnik"]
irb(main):002:0> Wordnik.configure do |config|
irb(main):003:1* config.api_key = 'myapikey'
irb(main):004:1> config.username =
irb(main):005:1* 'username'
irb(main):006:1> config.password =
irb(main):007:1* 'password'
irb(main):008:1> config.auth_token =
irb(main):009:1* 'token'
irb(main):010:1> end
=> ["account", "analytics", "corpus", "document", "feeds", "health", "partner", "partners", "suggest", "system", "tag", "user", "users", "word", "wordList", "wordLists", "words"]
irb(main):011:0> Wordnik.words.get_word_list_words('23456')
D, [2018-02-24T23:04:58.664191 #33772] DEBUG -- : 
  body: {}


ClientError: user does not have access to word list 630014
from /Library/Ruby/Gems/2.3.0/gems/wordnik-4.12/lib/wordnik/response.rb:28:in `catch_errors'
from /Library/Ruby/Gems/2.3.0/gems/wordnik-4.12/lib/wordnik/response.rb:18:in `initialize'
from /Library/Ruby/Gems/2.3.0/gems/wordnik-4.12/lib/wordnik/request.rb:181:in `new'
from /Library/Ruby/Gems/2.3.0/gems/wordnik-4.12/lib/wordnik/request.rb:181:in `make'
from /Library/Ruby/Gems/2.3.0/gems/wordnik-4.12/lib/wordnik/request.rb:185:in `response'
from /Library/Ruby/Gems/2.3.0/gems/wordnik-4.12/lib/wordnik/resource_modules/word_list.rb:138:in `get_word_list_words'
from (irb):11
from /usr/bin/irb:11:in `<main>'
irb(main):012:0> 

Erin McKean

unread,
Feb 24, 2018, 7:44:54 PM2/24/18
to Wordnik API
Hmm, for some reason, when I try

Wordnik.words.get_word_list_words('testing-123', :auth_token => '$TOKEN', :api_key => '$KEY')

the 'auth_token' in the request is converted to 'authToken' which the API does not recognize, thus the error message. I'm looking into why this happens. 

HOWEVER, you can get what you need using the API URL and an http request library such at httparty, like so: 

query = {
 
"api_key"     => "$APIKEY"
}
headers
= {
 
"auth_token"  => "$TOKEN",
}


response
= HTTParty.get(
 
"http://api.wordnik.com/v4/wordList.json/$listPermalink/words",
 
:query => query,
 
:headers => headers
)


puts response
.body


I've tested this code and it works. :)

Good luck!

Erin

Erin McKean

unread,
Feb 24, 2018, 7:47:06 PM2/24/18
to Wordnik API
I forgot to add you can also use 

Wordnik.account.authenticate('$USERNAME', :password => '$PASSWORD')


to get the user token inside your Ruby script.

Marilyn Roxie

unread,
Feb 24, 2018, 8:17:52 PM2/24/18
to Wordnik API
Hello Erin,

The first method you posted with httparty worked for me! Thanks a bunch! the Wordnik.account.authenticate('$USERNAME', :password => '$PASSWORD') code doesn't seem to work followed with Wordnik.words.get_word_list_words('listname', :auth_token => '$TOKEN', :api_key => '$KEY') for me for whatever reason, but I am not too bothered about it since I got what I wanted the other way.

Thanks again,
~Marilyn
Reply all
Reply to author
Forward
0 new messages