在我们的 Android 应用程序中,我们能够在没有任何用户交互的情况下获取身份验证 token (目的是了解从我们的应用程序接收到 api 调用,而不是为了获取任何用户信息)
我们使用:
GoogleAuthUtil.getToken(context, anyAccount, "audience:server:client_id:" + MY_CLIENT_ID);
我们如何做一些类似于验证来自 chrome 扩展程序的 api 调用的事情?
更新: 这就是我们如何在 Android 上获得无用户交互的身份验证: http://android-developers.blogspot.co.il/2013/01/verifying-back-end-calls-from-android.html
最佳答案
幸运的是在调用getAuthToken时,你可以传递一个标志 ('interactive': true)
或 ('interactive': false)
('interactive': true)
- If you invoke the API in interactive mode, the user is shown a sign in and/or approval UI when necessary, as shown in the screenshot below:
('interactive': false)
- If you invoke the API in silent mode, the API will only return a token if it's possible to produce one without showing any UI. This is useful in cases when an app is doing the flow at app startup, for example, or in general in cases where there is no user gesture involved.
注意
The best practice we suggest is to use silent mode when there is no user gesture involved and use interactive mode if there is a user gesture (for example, the user clicked the Sign In button in your app). Note that we do not enforce any gesture requirement.
关于android - Chrome 扩展 : Authenticate with backend without user interaction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38421545/