我正在尝试从经过身份验证的用户(使用Firebase身份验证)检索Google Access令牌以访问Google REST API,例如YouTube Data API.
我已经在Firebase-UI for Android - Auth库的帮助下成功地在我的应用中集成了Google登录.从FirebaseUser.getToken()
方法检索的令牌不是REST API的有效Google Access令牌.
user.getToken(true).addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
public void onComplete(@NonNull Task<GetTokenResult> task) {
if (task.isSuccessful()) {
String token = task.getResult().getToken();
// 'token' is not a Google Access Token
}
}
});
Run Code Online (Sandbox Code Playgroud)
在Google Sign-In for Web指南中,可以通过调用获取访问令牌var token = result.credential.accessToken;
,但我在Android中找不到类似的方法.
有什么投入?如果我没有提供足够的信息,请在这里发表评论.谢谢 :)
如何在Firebase托管中安装Wordpress?我试图找一篇文章来帮我安装,但我没找到.
我正在使用Firebase UI Auth处理我的应用中的电子邮件登录,并启用了磁盘持久性,以便可以脱机访问数据.但是在应用程序中登录了一个小时之后,我在logcat中收到了这个警告.
W/PersistentConnection: pc_0 - Auth token revoked: expired_token (Auth token is expired.)
W/PersistentConnection: pc_0 - Authentication failed: invalid_token (Invalid claim 'kid' in auth header.)
W/PersistentConnection: pc_0 - Authentication failed: invalid_token (Invalid claim 'kid' in auth header.)
... repeatedly
... and sometimes
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
Run Code Online (Sandbox Code Playgroud)
当我收到此消息时,应用程序无法执行任何firebase保存/检索新的未缓存数据操作,除非我签出/清除数据然后再次登录.然后问题在登录后大约一个小时后再次发生.我已经按照此令牌刷新故障排除指南(将我的调试和生产密钥SHA1添加到Firebase和Google API控制台)并且它无法解决此问题.我google-services.json
在我的项目中使用了Firebase控制台中的最新版本.
我也在使用最新的Firebase SDK和Play服务库
compile 'com.google.android.gms:play-services-auth:9.2.1'
compile 'com.google.firebase:firebase-core:9.2.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.google.firebase:firebase-auth:9.2.1'
compile 'com.firebaseui:firebase-ui-auth:0.4.3'
Run Code Online (Sandbox Code Playgroud)
我在Application
课堂上启用了持久性.
public class Application extends android.app.Application …
Run Code Online (Sandbox Code Playgroud) android firebase firebase-authentication firebase-realtime-database firebaseui
我目前正在按如下方式设置Firebase Analytics属性,例如性别和用户名:
firebaseAnalytics.setUserProperty("username", /*someusername*/);
Run Code Online (Sandbox Code Playgroud)
成功设置它们后,我希望能够在应用程序内的其他位置接收它们。某种程度上类似于Firebase数据库。
这可能吗?我在Firebase文档中找不到任何解释。