Answer the question
In order to leave comments, you need to log in
How to make authorization in the application through Google+?
Hello!
Now I am developing an application for Android and I want to enable users to log in / register by email and through social networks (Google+, VK, Facebook, etc). I did authorization by email, everything works, but there were difficulties with authorization through social networks. networks, such as Google+. Please answer any questions!
Table 'Users' Table 'Social Account'
_________________ _________________
| id_user | | id
| email | | id_user
| hash_password | | name_network
| token | | id_user_network
...
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.server_client_id))
.build();
...
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
String idToken = acct.getIdToken();
mIdTokenTextView.setText("ID Token: " + idToken);
// Вот здесь нужно отправить полученный токен на сервер и вызвать функцию проверки этого токена
} else {
mIdTokenTextView.setText("ID Token: null");
}
Answer the question
In order to leave comments, you need to log in
The action plan is correct.
As for checking tokens, go to the official website and read
https://developers.google.com/identity/sign-in/web...
https://developers.google.com/api-client-library/p
... Google has a ready SDK , you just need to connect it.
A call that returns information about the user:
Should return HTTP 200 OK and JSON with a list of fields.
{
"aud": GOOGLE_CLIENT_ID,
"sub": GOOGLE_USER_ID,
... Ещё какие-то поля ..
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question