本文整理汇总了TypeScript中angular2-oauth2/oauth-service.OAuthService.logOut方法的典型用法代码示例。如果您正苦于以下问题:TypeScript OAuthService.logOut方法的具体用法?TypeScript OAuthService.logOut怎么用?TypeScript OAuthService.logOut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2-oauth2/oauth-service.OAuthService
的用法示例。
在下文中一共展示了OAuthService.logOut方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(
private oauthService: OAuthService,
public feature: FeatureService,
private router: Router,
private http: Http) {
try {
this.oauthService.loginUrl = 'https://accounts.google.com/o/oauth2/v2/auth';
this.oauthService.redirectUri = window.location.origin;
this.oauthService.clientId = '280436316587-pc2v79112kdqu0jiruu56m92s8nr4s42.apps.googleusercontent.com';
this.oauthService.scope = 'openid profile email';
this.oauthService.oidc = true;
this.oauthService.setStorage(sessionStorage);
this.oauthService.logoutUrl = null;
this.oauthService.tryLogin({
onTokenReceived: context => {
if (window.location.hash && window.location.hash.indexOf('access_token') !== -1) {
this.router.navigate(['home']);
}
},
validationHandler: context => {
let search = new URLSearchParams();
search.set('access_token', context.accessToken);
let v = http.get('https://www.googleapis.com/oauth2/v3/tokeninfo', { search })
.toPromise().then(x => {
if (x.json().aud !== oauthService.clientId) {
console.error('Wrong client_id');
oauthService.logOut();
}
});
return v;
}
});
if (!this.oauthService.hasValidAccessToken()) {
this.oauthService.logOut();
}
} catch (e) {
console.error(e);
}
}
示例2: logout
public logout() {
this.oauthService.logOut();
}
示例3: logoff
public logoff() {
this.oauthService.logOut();
this.router.navigate(['/home']);
}
示例4:
.toPromise().then(x => {
if (x.json().aud !== oauthService.clientId) {
console.error('Wrong client_id');
oauthService.logOut();
}
});