I recently started to explore the Google Identity Kit using golang on the App Engine. I was going off of the samples in the googlesamples/identity-toolkit-go. In looking at the code, I found some appengine packages for the following:
"google.golang.org/appengine"
"google.golang.org/appengine/datastore"
For the GAE Golang application that I am working on, I use the GAE SDK to run the application using goapp run
. However, in my code, I only reference
"appengine"
"appengine/datastore"
because this points to the golang src located in the extracted go appengine sdk.
Do I need to be using the google.golang.org
appengine packages instead?
I only found this out after realizing that the appengine.Context that is expected by the identity kit methods did not match what I was using. I received this error
`cannot use c (type "appengine".Context) as type "golang.org/x/net/context".Context in argument to client.ValidateToken. "appengine".Context does not implement "golang.org/x/net/context".Context (missing Deadline method)`
despite me using appengine.NewContext(r)
as the example explained.
I recommend using the google.golang.org/appengine
packages if you can. They play nicer with the language, primarily because of the reason you mention (context
is a net/context
), and also because the libraries are newer and often have more features. In particular if you plan to use other Google services (like Google Cloud Storage) you'll have a much easier time using the newer libraries.
But they're also better because - since they're just regular, importable packages - they play nicer with the standard set of go tools: goimports
for auto-formatting, gocode
for autocomplete, etc..
However they are not entirely complete. There are some features missing or deprecated. In my experience it used to be that the major missing feature was the aetest
package, which has since been ported, so there's now very few reasons not to switch.