Store Facebook Credential in Android for Google Smart Lock Password

允我心安 提交于 2019-12-01 15:59:05

问题


Store Facebook Credential in Google Smart Lock Password

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();

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();

回答1:


I was able to get what I believe to be a working version of Smart Lock saving Facebook login credentials.

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();

I'm not completely familiar with the Facebook API, but I think you could get the email and username from the Facebook SDK.

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".



来源:https://stackoverflow.com/questions/34414532/store-facebook-credential-in-android-for-google-smart-lock-password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!