evernote / evernote-oauth-ruby Goto Github PK
View Code? Open in Web Editor NEWEvernote OAuth / Thrift API client library for Ruby
License: Other
Evernote OAuth / Thrift API client library for Ruby
License: Other
In my Rails 4.1.7 application I'm trying to connect with Evernote through this Oauth gem. I have the following code to connect: (of course with the callback URL specific to my installation)
def evernote_web_auth
client = EvernoteOAuth::Client.new
request_token = client.request_token(oauth_callback: 'YOUR CALLBACK URL')
session[:request_token] = request_token
request_token
end
In need to put the request_token
in the session because I need it later when I return on the callback url that processes the rest. From Rails 4.1 it's not possible anymore to save entire objects in a session, so I have to serialize it. The size of the Oauth object was to large to put in a session as JSON or Hash (Rails has a maximum of 4kb). So I tried to serialize the object with Marshal or MessagePack, but that gave me an encoding error: Encoding::UndefinedConversionError "\x9C" from ASCII-8BIT to UTF-8
Then I tried to force UTF-8/ISO-8859-1 encoding:
session[:request_token] = Marshal.dump(request_token).force_encoding('ISO-8859-1')
That worked, but resulted in a ArgumentError: dump format error for symbol(0x45)
error. I tried everything, but nothing seems to work. Any ideas how to solve this?
Gemfile
gem 'evernote_oauth'
gem 'omniauth-evernote'
omniauth.rb
provider :evernote, EVERNOTE_CONSUMER_KEY, EVERNOTE_CONSUMER_SECRET ,:client_options => { :site => 'https://www.evernote.com' }
token = user.oauth_token
client = EvernoteOAuth::Client.new(token: token)
note_store = client.note_store
Evernote::EDAM::Error::EDAMSystemException: Evernote::EDAM::Error::EDAMSystemException
from /home/startup/.rvm/gems/ruby-1.9.3-p385/gems/evernote-thrift-1.23.1/lib/Evernote/EDAM/user_store.rb:180:in recv_getNoteStoreUrl' from /home/startup/.rvm/gems/ruby-1.9.3-p385/gems/evernote-thrift-1.23.1/lib/Evernote/EDAM/user_store.rb:169:in
getNoteStoreUrl'
from /home/startup/.rvm/gems/ruby-1.9.3-p385/gems/evernote_oauth-0.1.6/lib/evernote_oauth/thrift_client_delegation.rb:11:in method_missing' from /home/startup/.rvm/gems/ruby-1.9.3-p385/gems/evernote_oauth-0.1.6/lib/evernote_oauth/note_store.rb:8:in
note_store'
from (irb):12
from /home/startup/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in start' from /home/startup/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in
start'
from /home/startup/.rvm/gems/ruby-1.9.3-p385/gems/railties-3.2.8/lib/rails/commands.rb:41:in <top (required)>' from script/rails:6:in
require'
from script/rails:6:in `
The typo in the following line means you will never save the note for the resource:
https://github.com/evernote/evernote-oauth-ruby/blob/master/lib/evernote/edam/type/resource.rb#L23
I requested full access for my API key and got an email response from Evernote that it had been granted.
I can successfully do this:
client.note_store.listNotebooks
and get a list of notebooks.
But when I do this:
client.note_store.findNotes(Evernote::EDAM::NoteStore::NoteFilter.new, 0, 10).first.tags.first.parent
I get this:
Evernote::EDAM::Error::EDAMUserException: Evernote::EDAM::Error::EDAMUserException
from /Users/lkenyan/.rvm/gems/ruby-2.0.0-p247@revolution_gemset/gems/evernote-thrift-1.25.1/lib/Evernote/EDAM/note_store.rb:450:in `recv_findNotes'
from /Users/lkenyan/.rvm/gems/ruby-2.0.0-p247@revolution_gemset/gems/evernote-thrift-1.25.1/lib/Evernote/EDAM/note_store.rb:440:in `findNotes'
from /Users/lkenyan/.rvm/gems/ruby-2.0.0-p247@revolution_gemset/gems/evernote_oauth-0.2.3/lib/evernote_oauth/thrift_client_delegation.rb:11:in `method_missing'
from (irb):70
from /Users/lkenyan/.rvm/gems/ruby-2.0.0-p247@revolution_gemset/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /Users/lkenyan/.rvm/gems/ruby-2.0.0-p247@revolution_gemset/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /Users/lkenyan/.rvm/gems/ruby-2.0.0-p247@revolution_gemset/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
And help is appreciated! Thanks.
Hi,
Can the library be used from behind a proxy? If yes, could you provide a short example or link how to do so?
Thanks
Christian
I'm having an issue after upgrading to Ruby 2.1.0, with creating notes with binary data. I get a conversion error: Encoding::UndefinedConversionError: "\xC7" from ASCII-8BIT to UTF-8
Here's what I do to replicate with any pdf file:
client = EvernoteOAuth::Client.new(config)
pdf = File.open('test.pdf', 'rb') { |io| io.read }
file_name='test.pdf'
hexdigest = Digest::MD5.new.hexdigest(pdf)
data = Evernote::EDAM::Type::Data.new(:size=> pdf.size, :bodyHash=> hexdigest, :body=>pdf)
resource_attributes = Evernote::EDAM::Type::ResourceAttributes.new(:fileName => file_name)
resource = Evernote::EDAM::Type::Resource.new(:mime=>'application/pdf', :data=>data, :attributes=>resource_attributes)
content = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">'+ %Q{ <en-note><en-media type='#{resource.mime}' hash='#{hexdigest}'/></en-note>}
note = Evernote::EDAM::Type::Note.new(:title=> title, :content=> content, :resources=>[resource], :notebookGuid=>'notebook_guid'])
client.note_store.createNote(note)
Here's the backtrace:
thrift-0.9.1/lib/thrift/bytes.rb:81:in `encode'
thrift-0.9.1/lib/thrift/bytes.rb:81:in `convert_to_utf8_byte_buffer'
thrift-0.9.1/lib/thrift/protocol/binary_protocol.rb:110:in `write_string'
thrift-0.9.1/lib/thrift/client.rb:35:in `write'
thrift-0.9.1/lib/thrift/client.rb:35:in `send_message'
evernote-thrift-1.25.1/lib/Evernote/EDAM/note_store.rb:678:in `send_createNote'
evernote-thrift-1.25.1/lib/Evernote/EDAM/note_store.rb:673:in `createNote'
evernote_oauth-0.2.2/lib/evernote_oauth/thrift_client_delegation.rb:11:in `method_missing'
This might be an evernote-thrift issue.
I'm getting this error quite a bit, and I'm honestly having some trouble tracking it down. I think it's happening when I use the notes
accessor on a SyncChunk object.
(I'm really new to Ruby, so perhaps I'm using the wrong approach.)
When I try access Notes from a NoteList in a Business NoteStore, I get an undefined method error.
Here's a snipet of code I use:
client = EvernoteOAuth::Client.new(config)
filters = Evernote::EDAM::NoteStore::NoteFilter.new
filters.notebookGuid = "NOTEBOOK GUID"
note_list = client.business_note_store.findNotes(filters, 0, 100)
note_list.notes
The NoteList class tries to look at note_store instead of business_note_store, which is correct only for a non-business NoteBook.
My workaround is to do this:
note_list.instance_variable_get("@notes")
Is there a better way to get notes from a Business NoteList?
After calling request_token.authorize_url, I seem to be getting an incorrect url path with '/oauth/authorize' instead of '/OAuth.action' in the URL. I have sandbox set to true.
The code I have now that works is:
client = EvernoteOAuth::Client.new(
consumer_key: 'my_evernote_key',
consumer_secret: 'my_evernote_secret',
sandbox: true
)
request_token = client.request_token(:oauth_callback => my_callback_url)
request_token.authorize_url.gsub('/oauth/authorize', '/OAuth.action')
RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.
There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.
I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!
Appendix:
If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies
p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.
Hi @rekotan, I was wondering if there is a Ruby-based API client to access the business-related endpoints? I know this library authenticates to the business note store, but I'd like to also access the other features, such as listing business users, getting attributes, inviting, etc.
Is there any Ruby code to do this already, or could it be added?
Thanks!
NameError: undefined local variable or method
note_store' for #Evernote::EDAM::NoteStore::NoteList:0x007fb000e60f48`
This is in gem 0.2.0
. I had to revert to 0.1.8
which works fine.
I get this error when I call notes
or notes?
on a NoteList. something like this.
1 note_list = client.note_store.findNotes(filter,0,99)
2 notes = note_list.notes
line 2 raises the exception, but with no stack trace of its own. This isn't happening in my code. line 1 works fine. Threw me for a loop.
When I want to ge the access_token, I get a Error:
access_credentials = request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])
I'm trying to connect through OAuth, but I'm having some difficulties with that. I have the following method in my controller (of course with a correct callback url):
def evernote_web_auth()
client = EvernoteOAuth::Client.new
request_token = client.request_token(oauth_callback: 'my_callback_url')
request_token
end
Following with this code to generate the the authorization url: evernote_web_auth().authorize_url
. This works, and I can authorize with my sandbox account. After authorizing, I get redirected to the same controller that contains the following code:
request_token = evernote_web_auth()
access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier])
This should work (like the guide explained). As you can see, it uses the same method as I used to generate the authorization url to perform .get_access_token
on, but this time it results in a 401 - Unauthorized
error.
My consumer key and secret are correct because I can generate the authorization url. So, what's wrong with the gem?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.