How does the service identify the user?

Use Case:

The user takes a beautiful photo and wants to save it in his evernote account.

enter image description here

  • The user allows the use of OAuth 2.0. The service saves its credentials.
  • After completing the OAuth 2.0 dance, the service adds a Save to Evernote contact.
  • The service then subscribes for updates in this user timeline by inserting a subscription for the timeline collection.
  • The user activates the contact. Save to Evernote is now fully configured.
  • Over time, the user takes pictures.
  • A user shares a photo using Save to Evernote. This makes the time map associated with this photo available for service.
  • Since the service is subscribed to timeline updates, a notification is sent to your service. This notification refers to a timeline element containing a shared photo.
  • The service checks the notification and uses the included identifier to obtain a timeline map containing the photo.
  • Next, the service checks the timeline element and uses the attachment identifier to retrieve the bytes of the photo.
  • The service uploads a photo to an Evernote user.
  • Finally, the service creates a new temporary card and inserts it into the user's time card with a success message.

From the Mirror API Documentation , a message appears stating that after the user shares a timeline element, the service receives a POST something like this:

{ "collection": "timeline", "itemId": "3hidvm0xez6r8_dacdb3103b8b604_h8rpllg", "operation": "UPDATE", "userToken": "harold_penguin", "verifyToken": "random_hash_to_verify_referer", "userActions": [ { "type": "SHARE" } ] } 

Is userToken the value I get when I first authenticate the application? If so, can I use this value to connect the POST received from Glass with the user stored in my database? If not, how can I connect the shared resource to my service, contact the Glass user so that my service can perform services specific to this user on their behalf?

+4
source share
1 answer

userToken is the field that you use to correlate the notification with the user who called it.

You set userToken when creating a subscription for this user. No matter what value you specify when inserting a subscription, it is provided as a userToken for all the notifications it gives. This means that when creating a subscription, you always want to use unique identifiers that your system can correlate with the correct user.

For instance:

  • Jane authenticates with your service. Jane has a unique user ID of 42 in your Glassware database.
  • During authentication, you subscribe to her timeline collection by pasting this subscription:

     { "collection": "timeline" "userToken": "42", "callbackUrl": "https://example.com/notify/callback" } 
  • Jane shares a photo with your dishes.
  • A notification is sent to your service. It looks something like this:

     { "collection": "timeline", "itemId": "3hidvm0xez6r8_dacdb3103b8b604_h8rpllg", "operation": "UPDATE", "userToken": "42", "userActions": [ { "type": "SHARE" } ] } 
  • Your Glassware uses the userToken property to find the correct user: Jane.

The rest of the story goes on as you describe in your question.

+3
source

All Articles