How can I determine a user_id based on an email address in App Engine?

前端 未结 2 1679
生来不讨喜
生来不讨喜 2020-12-05 03:41

The newest App Engine SDK (1.2.1) has an API call to compute an ID for a user account based on his email address. (The ID remains the same even if the user changes his addr

相关标签:
2条回答
  • 2020-12-05 04:14

    To make the proposed solution work with NDB, just add use_cache=False, use_memcache=False to the get method. That is: obj = key.get(use_cache=False, use_memcache=False) This guarantees getting the entity from the Datastore with the user_id param populated (only if this is a valid Google account).

    0 讨论(0)
  • 2020-12-05 04:20

    The current workaround is to create a User object, store it to the datastore, and fetch it again. If the email corresponds to a valid Google account, the User object in the returned entity will have its user_id field populated.

    0 讨论(0)
提交回复
热议问题