admin管理员组文章数量:1332977
is it possible to only receive the serverAuthCode
with the Credential Manager [1] in an Android App written in Java ?
Our backend expects only this information so it may make the request to Google to receive info about the user thats trying to login.
My current implementation is:
CredentialManager manager = CredentialManager.create(getApplicationContext());
GetGoogleIdOption googleIdOption = new GetGoogleIdOption.Builder()
.setFilterByAuthorizedAccounts(true) // only existing google accounts, no "create new google account" screen
.setAutoSelectEnabled(true)
.setServerClientId("web_client_id")
.build();
GetCredentialRequest request = new GetCredentialRequest.Builder()
.addCredentialOption(googleIdOption)
.build();
CredentialManagerCallback<GetCredentialResponse, GetCredentialException> credentialManagerCallback = new CredentialManagerCallback<GetCredentialResponse, GetCredentialException>() {
@Override
public void onResult(GetCredentialResponse result) {
// result here has all the data of the user, like email, name
// wanted: only serverAuthToken to send over to the backend which is then makeing the google api request
}
@Override
public void onError(@NonNull GetCredentialException error) {
// handle error
}
};
manager.getCredentialAsync(
_activity_instance,
request,
null,
Executors.newSingleThreadExecutor(),
credentialManagerCallback
);
[1]
is it possible to only receive the serverAuthCode
with the Credential Manager [1] in an Android App written in Java ?
Our backend expects only this information so it may make the request to Google to receive info about the user thats trying to login.
My current implementation is:
CredentialManager manager = CredentialManager.create(getApplicationContext());
GetGoogleIdOption googleIdOption = new GetGoogleIdOption.Builder()
.setFilterByAuthorizedAccounts(true) // only existing google accounts, no "create new google account" screen
.setAutoSelectEnabled(true)
.setServerClientId("web_client_id")
.build();
GetCredentialRequest request = new GetCredentialRequest.Builder()
.addCredentialOption(googleIdOption)
.build();
CredentialManagerCallback<GetCredentialResponse, GetCredentialException> credentialManagerCallback = new CredentialManagerCallback<GetCredentialResponse, GetCredentialException>() {
@Override
public void onResult(GetCredentialResponse result) {
// result here has all the data of the user, like email, name
// wanted: only serverAuthToken to send over to the backend which is then makeing the google api request
}
@Override
public void onError(@NonNull GetCredentialException error) {
// handle error
}
};
manager.getCredentialAsync(
_activity_instance,
request,
null,
Executors.newSingleThreadExecutor(),
credentialManagerCallback
);
[1] https://developer.android/identity/sign-in/credential-manager
Share Improve this question asked Nov 20, 2024 at 16:45 pasklpaskl 6115 silver badges25 bronze badges1 Answer
Reset to default 1No, that is not possible. You can only receive an auth code if you use the Authorization APIs; Credential Manager is aimed at authentication and not authorization.
本文标签: javaOnly receive ServerAuthToken with Credential ManagerStack Overflow
版权声明:本文标题:java - Only receive ServerAuthToken with Credential Manager? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742343717a2457101.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论