我遵循Instagram API文档来实现Implicit Authentication:
我在项目中所做的工作(角度2):
signup.component.html
<div class="row">
<div class="col-12 text-center">
<button type="button" class="btn btn-sm instagram" (click)="signInWithInsta()" style="background-color: white">
<i class="fa fa-instagram"></i> Instagram</button>
</div>
</div>
signup.component.ts
signInWithInsta(): void {
let url =
'https://api.instagram.com/oauth/authorize/?client_id=' + Constants.INSTAGRAM_CLIENT_ID +
'&redirect_uri=' + encodeURIComponent('https://localhost:4200/') +
'&response_type=token';
window.location.href = url;
}
结果:
我收到了一个回调URL: https://localhost:4200/#access_token=xxxxxxx.xxxxx.fxxxxxxxxxxx
我的问题:此回调网址在浏览器中返回,仅存在几秒钟,并更改为:https://localhost:4200/index.html#/access_token
如何以编程方式捕获代码中的access_token。
任何建议都值得赞赏