Reputation: 3111
I want to programatically generate the private note link to an Evernote note. (In my scenario, it is just me as the developer authenticating using my auth token - there is no OAuth involved, but I am assuming the process would be the same.)
I've read article "Note Links - Link directly to individual notes from anywhere" at https://dev.evernote.com/doc/articles/note_links.php but it covers evernote://... links only.
What is the proper way to generate a private Evernote note link?
Upvotes: 0
Views: 335
Reputation: 3469
You have to share a note and only send the URL to the person in question. Evernote URLs were designed to keep people from guessing them so if you only share the URL with one other person you can reasonably assume that they are the only one that has access to the note. The URL scheme is below
[EN_URL]/shard/[shardId]/sh/[noteGuid]/[shareKey]
where
[EN_URL] is your URL (https://sandbox.evernote.com for the sandbox or https://www.evernote.com for the production service
[shardId] the Shard id that the note user is on (can be accessed via userStore.getUser().shardId)
[noteGuid] is the note guid (can be access via note.guid)
[shareKey] is the share key from sharing the note (returned from the note.shareNote() method)
You can see all of this in the Evernote API docs: https://dev.evernote.com/doc/articles/note-sharing.php
see the sanbox python example below:
from evernote.api.client import EvernoteClient
import evernote.edam.type.ttypes as Types
EN_URL="https://sandbox.evernote.com"
evernote_auth_token = "Your auth or dev token here"
client = EvernoteClient(token=evernote_auth_token, sandbox=True)
user_store = client.get_user_store()
note_store = client.get_note_store()
note = Types.Note() #create a note object
#define a sample note
note.title='some title'
note.content = '<?xml version="1.0" encoding="UTF-8"?>'
note.content += '<!DOCTYPE en-note SYSTEM ' \
'"http://xml.evernote.com/pub/enml2.dtd">'
note.content += '<en-note>'+'hi mom!'+'<br/>'
note.content += '</en-note>'
note=note_store.createNote(note) # create the note
user=user_store.getUser(evernote_auth_token)
shardId=user.shardId
shareKey=note_store.shareNote(evernote_auth_token, note.guid)
evernote_url="%s/shard/%s/sh/%s/%s" % (EN_URL,shardId,note.guid,shareKey)
Upvotes: 0
Reputation: 774
It depends on what you want to do. https:// links will open in your browser, whereas evernote:// ones will open in the client application (if there's one installed).
Sharing a note privately means that you share a note to individuals. Only these individuals will be able to access the note after being authenticated. On the contrary, public sharing means that you share the note with everybody that knows the url. From what I understand about your case, I'd say that you don't have to "share" a note. You don't want to "invite" someone to access a note but just want that the owner of a note can access it via a link. Am I right ?
If so, you have to stick to the documentation at https://dev.evernote.com/doc/articles/note_links.php The main difficulty being to handle the different cases mentioned in the doc.
Hope this helps.
Upvotes: 1