-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathevernote-mode.patch
More file actions
87 lines (77 loc) · 3.02 KB
/
evernote-mode.patch
File metadata and controls
87 lines (77 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
diff --git a/evernote-mode.el b/evernote-mode.el
index 313a1dc..e434841 100644
--- a/evernote-mode.el
+++ b/evernote-mode.el
@@ -162,6 +162,9 @@
"*Non-nil means that password cache is enabled.
It is recommended to encrypt the file with EasyPG.")
+(defvar evernote-developer-token nil
+ "*An developer token of your evernote")
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Interface for evernote-browsing-mode.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -550,6 +553,8 @@ It is recommended to encrypt the file with EasyPG.")
"Login"
(interactive)
(if (called-interactively-p) (enh-clear-onmem-cache))
+ (if evernote-developer-token
+ (enh-command-login-token evernote-developer-token)
(unwind-protect
(let* ((cache (enh-password-cache-load))
(usernames (mapcar #'car cache))
@@ -567,7 +572,7 @@ It is recommended to encrypt the file with EasyPG.")
(enh-command-login username passwd)
(setq evernote-username username)
(enh-password-cache-save (enutil-aset username cache passwd)))))
- (enh-password-cache-close)))
+ (enh-password-cache-close))))
(defun evernote-open-note (&optional ask-notebook)
@@ -1769,6 +1774,14 @@ It is recommended to encrypt the file with EasyPG.")
(enutil-to-ruby-string passwd))))
+(defun enh-command-login-token (token)
+ "Issue login command"
+ (enh-command-issue
+ (format ":class => %s, :auth_token => %s"
+ (enutil-to-ruby-string "AuthCommand")
+ (enutil-to-ruby-string token))))
+
+
(defun enh-command-get-notebook-attrs ()
"Issue listnotebooks command"
(let ((reply (enh-command-issue
diff --git a/ruby/bin/enclient.rb b/ruby/bin/enclient.rb
index 9067bad..a13ae8a 100755
--- a/ruby/bin/enclient.rb
+++ b/ruby/bin/enclient.rb
@@ -426,13 +426,17 @@ module EnClient
class AuthCommand < Command
- attr_accessor :user, :passwd
+ attr_accessor :user, :passwd, :auth_token
def exec_impl
- Formatter.to_ascii @user, @passwd
+ Formatter.to_ascii @user, @passwd, @auth_token
server_task do
+ if @auth_token
+ sm.authenticate_with_token @auth_token
+ else
sm.authenticate @user, @passwd
+ end
LOG.info "Auth successed: auth_token = '#{sm.auth_token}', shared_id = '#{sm.shared_id}'"
tm.put SyncTask.new(sm, dm, tm)
server_task true do # defer reply until first sync will be done.
@@ -1175,6 +1179,15 @@ module EnClient
@note_store = create_note_store @shared_id
end
+ def authenticate_with_token(token)
+ @user_store = create_user_store
+ user = @user_store.getUser token
+ @auth_token = token
+ @shared_id = user.shardId if user
+ @expiration = 60 * 60 * 24 * 365
+ @note_store = create_note_store @shared_id
+ end
+
def refresh_authentication(current_time)
if current_time > @expiration - REFRESH_LIMIT_SEC * 1000
LOG.info "refresh authentication"