本文整理汇总了TypeScript中angular2-oauth2/oauth-service.OAuthService类的典型用法代码示例。如果您正苦于以下问题:TypeScript OAuthService类的具体用法?TypeScript OAuthService怎么用?TypeScript OAuthService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OAuthService类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(private authService: OAuthService) {
super();
if (this.authService && this.authService.getIdToken()) {
console.log(this.authService.authorizationHeader());
this.headers.append('Authorization', this.authService.authorizationHeader());
}
}
开发者ID:cackharot,项目名称:fbeazt,代码行数:7,代码来源:MyHttpBaseRequestOptions.ts
示例2: constructor
constructor(private oauthService: OAuthService, private router: Router) {
this.oauthService.loginUrl = "https://steyer-identity-server.azurewebsites.net/identity/connect/authorize"; //Id-Provider?
this.oauthService.logoutUrl = "https://steyer-identity-server.azurewebsites.net/identity/connect/endsession?id_token={{id_token}}";
this.oauthService.redirectUri = window.location.origin + "/home";
this.oauthService.clientId = "spa-demo";
this.oauthService.scope = "openid profile email voucher";
this.oauthService.issuer = "https://steyer-identity-server.azurewebsites.net/identity";
this.oauthService.oidc = true;
this.oauthService.setStorage(localStorage);
this.oauthService.tryLogin({});
}
开发者ID:yooynas,项目名称:angular-2-rc4-router-sample-oauth,代码行数:15,代码来源:app.component.ts
示例3: 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);
}
}
开发者ID:cackharot,项目名称:fbeazt,代码行数:41,代码来源:app.component.ts
示例4: canActivate
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
let token = this.authService.getIdToken();
if (state.url !== '/login' && !token) {
this.authService.initImplicitFlow();
return false;
}
return true;
}
开发者ID:cackharot,项目名称:fbeazt,代码行数:8,代码来源:AuthGuard.ts
示例5: canActivate
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot) {
var hasIdToken = this.oauthService.hasValidIdToken(); //ID --> who the user is
var hasAccessToken = this.oauthService.hasValidAccessToken(); // backend-service
return (hasIdToken && hasAccessToken);
}
开发者ID:manfredsteyer,项目名称:angular2-router-angular_berlin-july-2017,代码行数:9,代码来源:flight-booking.guard.ts
示例6: canActivate
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot) {
var hasIdToken = this.oauthService.hasValidIdToken(); // Who the user
var hasAccessToken = this.oauthService.hasValidAccessToken(); // access rest-service
return (hasIdToken && hasAccessToken);
}
开发者ID:yooynas,项目名称:angular-2-rc4-router-sample-oauth,代码行数:9,代码来源:flight-booking.guard.ts
示例7: canActivate
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot) {
var hasIdToken = this.oauthService.hasValidIdToken();
var hasAccessToken = this.oauthService.hasValidAccessToken();
return (hasIdToken && hasAccessToken);
}
开发者ID:PedroDavid1367,项目名称:DBSP.Angular2.ReliableSamples,代码行数:9,代码来源:flight-booking.guard.ts
示例8: function
$rootScope.$on("$stateChangeStart", function (event: angular.IAngularEvent, toState: IState, toParams, fromState: IState, fromParams) {
if (DEBUG) return;
let loggedIn = oauthService.hasValidAccessToken()
&& oauthService.hasValidIdToken();
if (toState.data && toState.data.protected && !loggedIn) {
event.preventDefault();
var requestedUrl = $state.href(toState, toParams);
$state.transitionTo("home", { requestedUrl: requestedUrl });
}
});
开发者ID:CodebustersMarcel,项目名称:full,代码行数:16,代码来源:app.ts
示例9: userName
public get userName() {
var claims = this.oauthService.getIdentityClaims();
if (!claims) return null;
return claims.given_name;
}
开发者ID:PedroDavid1367,项目名称:DBSP.Angular2.ReliableSamples,代码行数:7,代码来源:home.component.ts
注:本文中的angular2-oauth2/oauth-service.OAuthService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论