Google API - Cross platform client credential auth

2019-09-15 17:57发布

问题:

We are using a framework called LibGdx, which allows you to write cross-platform code using only Java. We are developing for Android and iOS.

We have a datastore in Google cloud, as well as an Google app engine api we made to communicate with this datastore.

Now we want to secure this API, but cannot find good guidance on how to approach this for cross-platform. Since we have a mix of fb-login and email-login we need to use client credentials (i.e only our app is allowed to communicate with our API).

Using .NET you would send client credentials (Client ID/Cleint secret), then get an access token, not sure how to approach that in this scenario. We do not have any scopes or anything like that, we just want to secure our API so it can't just be called by anyone. So a simple Bearer-token would solve our issues. Just not sure where to begin.

回答1:

you should have a look at Firebase Authentication

https://firebase.google.com/docs/auth/

Firebase supports several login providers like Google and Facebook. You will receive a token from Firebase Authentication which you have to forward to your API at Google App Engine.

You can use the Firebase Admin SDK at Google App Engine to validate the Token again

https://firebase.google.com/docs/admin/setup