Angular 8-如何从回调路由中的url获取数据
如何从keydape服务器获取对我的授权组件的访问令牌。 授权url如下所示: 回调url位于中,下面是组件:Angular 8-如何从回调路由中的url获取数据,angular,Angular,如何从keydape服务器获取对我的授权组件的访问令牌。 授权url如下所示: 回调url位于中,下面是组件: import { Component, OnInit } from '@angular/core'; import {ActivatedRoute} from '@angular/router'; @Component({ selector: 'app-auth', templateUrl: './auth.component.html', styleUrls: ['./auth.
import { Component, OnInit } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
@Component({
selector: 'app-auth',
templateUrl: './auth.component.html',
styleUrls: ['./auth.component.scss']
})
export class AuthComponent implements OnInit {
constructor(private route: ActivatedRoute) { }
ngOnInit() {
console.log(this.route.snapshot);
console.log(this.route.snapshot);
}
}
成功登录后,access_令牌将从keydape返回,如下所示:
我的问题是,如何让它工作,并获得访问令牌。以下应该可以工作
this.route.queryParams.subscribe(params => {
const accesToken = this.route.snapshot.fragment
.split("&")[0]
.replace("/", "")
.split("=")[1];
});
只需从
location.hash中读取