У меня запущено приложение angular2 с основным веб-API aspnet. Все мои локальные логины работают отлично, я вызываю connect/token с именем пользователя и паролем, и возвращается accessToken.
Теперь мне нужно реализовать Google как внешний поставщик удостоверений. Я выполнил все шаги, описанные здесь, чтобы реализовать кнопку входа в Google. При входе пользователя в систему открывается всплывающее окно. Это код, который я создал для своей кнопки Google.
Код: Выделить всё
// Angular hook that allows for interaction with elements inserted by the
// rendering of a view.
ngAfterViewInit() {
// check if the google client id is in the pages meta tags
if (document.querySelector("meta[name='google-signin-client_id']")) {
// Converts the Google login button stub to an actual button.
gapi.signin2.render(
'google-login-button',
{
"onSuccess": this.onGoogleLoginSuccess,
"scope": "profile",
"theme": "dark"
});
}
}
onGoogleLoginSuccess(loggedInUser) {
let idToken = loggedInUser.getAuthResponse().id_token;
// here i can pass the idToken up to my server and validate it
}
Подробнее здесь: https://stackoverflow.com/questions/402 ... en-c-sharp