且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android客户端-使用Google Cloud Endpoints的Google App引擎身份验证

更新时间:2021-07-30 22:52:29

为了通过Google Cloud Endpoints将App Engine用户实例注入到API方法中,您确实需要在Android应用程序中使用Google帐户.您的Android代码中的服务构建器需要一个GoogleAccountCredential.

In order to get an App Engine user instance injected into your API method by Google Cloud Endpoints, you do need to be using a Google account in the Android app. The service builder in your Android code takes a GoogleAccountCredential.

您仍然可以支持自己的用户名和密码,但是您不能使用用户注入.

You can still support your own userid and password, but you can't leverage the user injection if you do.

如果您不想在Android应用中使用Google帐户,请忘记SHA1和API密钥.您将必须进行自己的身份验证.这取决于您的操作方式,但是您可以通过使用用户名和密码并返回令牌的API调用来开始会话.例如,所有其他API调用都可能使用该令牌并在返回结果之前检查其有效性.

If you're not going to use Google Accounts in the Android app, forget the SHA1 and API key. You're going to have to roll your own auth. It's up to you how you do this, but you might start your session with an API call that takes a username and password and returns a token. All other API calls might take that token and check it for validity before returning a result, for example.