在Android中将Facebook凭据存储为Google Smart Lock密码 [英] Store Facebook Credential in Android for Google Smart Lock Password
问题描述
使用Google Smart Lock密码存储Facebook凭据
Store Facebook Credential in Google Smart Lock Password
我能够在Smart Lock密码中存储基本的用户名/密码凭据.有很多有关Google凭据的文档和示例:
I was able to store basic username/password credentials in Smart Lock Password. There is plenty of documentation and examples for Google credentials:
GoogleSignInAccount gsa = signInResult.getSignInAccount();
Credential credential = new Credential.Builder(gsa.getEmail())
.setAccountType(IdentityProviders.GOOGLE)
.setName(gsa.getDisplayName())
.setProfilePictureUri(gsa.getPhotoUrl())
.build();
但是到目前为止,我还无法存储Facebook凭据.它应该是类似的东西.但是到底是什么呢?还是完全不同或不受支持?
But so far, I was unable to store a Facebook credential. It should be something similar. But what exactly? Or is it something completely different or not supported?
Credential credential = new Credential.Builder(<what goes here?!>)
.setAccountType(IdentityProviders.FACEBOOK)
.setName(<and here?>)
.setProfilePictureUri(<is this necessary?>)
.build();
推荐答案
我能够获得我认为是保存Facebook登录凭据的Smart Lock的工作版本.
I was able to get what I believe to be a working version of Smart Lock saving Facebook login credentials.
我的应用程序使用FB API登录.从那里,我将令牌发送到服务器,服务器又将用户的电子邮件和用户名发回给我.我这样存储该信息:
My app uses the FB API to login. From there I send a token to my server which in turn sends back the users email and username. I store that information like so:
Credential credential = new Credential.Builder(user.getEmail())
.setAccountType(IdentityProviders.FACEBOOK)
.setName(user.getName())
.build();
我对Facebook API并不完全熟悉,但是我认为您可以从Facebook SDK中获取电子邮件和用户名.
I'm not completely familiar with the Facebook API, but I think you could get the email and username from the Facebook SDK.
使用它保存用户FB凭据后,我可以在passwords.google.com上查看它们.密码显示为"With Facebook".
After using this to save the users FB credentials I am able to view them on passwords.google.com. The password shows as "With Facebook".
这篇关于在Android中将Facebook凭据存储为Google Smart Lock密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!