google mirror api - How does a service identify the user? -


use case:

a user takes beautiful photo , wants save evernote account.

enter image description here

  1. user authorizes oauth 2.0. service stores credentials.
  2. just after oauth 2.0 dance completes, service inserts contact called "save evernote".
  3. next, service subscribes updates in user's timeline inserting subscription timeline collection.
  4. the user activates contact. save evernote set up.
  5. over time, user takes photos.
  6. the user shares photo save evernote. makes timeline card associated photo accessible service.
  7. because service subscribed timeline updates, notification sent service. notification links timeline item containing shared photo.
  8. the service examines notification , uses included id fetch timeline card contains photo.
  9. next, service examines timeline item , uses attachment id fetch bytes of photo.
  10. the service uploads photo user's evernote.
  11. finally, service constructs new timeline card , inserts user's timeline card success message.

from mirror api documentation appears once user shares timeline item service receives post quite this:

{   "collection": "timeline",   "itemid": "3hidvm0xez6r8_dacdb3103b8b604_h8rpllg",   "operation": "update",   "usertoken": "harold_penguin",   "verifytoken": "random_hash_to_verify_referer",   "useractions": [     {       "type": "share"     }   ] } 

is usertoken value receive when first authenticating application? if can use value connect post received glass user saved in database? if not how connect share service's contact glass user service can perform services specific user on behalf?

the usertoken indeed field use correlate notification user triggered it.

you set usertoken when create subscription user. whatever value specify when insert subscription provided usertoken of notifications yields. means when create subscriptions, want use unique identifiers system can correlate correct user.

for example:

  1. jane authenticates service. jane has unique user id of 42 in glassware's database.
  2. at time of authentication, subscribe timeline collection inserting subscription:

    {   "collection": "timeline"   "usertoken": "42",   "callbackurl": "https://example.com/notify/callback" } 
  3. jane shares photo glassware.
  4. a notification sent service. looks this:

    {   "collection": "timeline",   "itemid": "3hidvm0xez6r8_dacdb3103b8b604_h8rpllg",   "operation": "update",   "usertoken": "42",   "useractions": [     {       "type": "share"     }   ] } 
  5. your glassware uses usertoken property correct user: jane.

the rest of story proceeds describe in question.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -