【发布时间】:2017-03-26 22:46:48
【问题描述】:
使用Firebase Web SDK,您可以按如下方式引用AccessToken:
const provider = new auth.GoogleAuthProvider();
provider.addScope('https://www.googleapis.com/auth/plus.login');
firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you a Google Access Token. You can use it to access the Google API.
var token = result.credential.accessToken;
// The signed-in user info.
var user = result.user;
// ...
});
您随后可以使用token 获取有关您的用户的更多信息;例如:
public getFirstName(token: string): Observable<string> {
const url = 'https://www.googleapis.com/oauth2/v3/userinfo?access_token=' + token;
return this.http.get(url).map(response => {
return response.json().given_name;
});
}
问题:如何使用AngularFire2 protocol 检索此访问令牌?
public loginGoogle() {
this.af.auth.login().then((authState) => {
authState.WHERE_IS_IT; // <<<-----
})
}
提前致谢! // 凯文
【问题讨论】:
标签: angular firebase-authentication angularfire2