angularjs 中的 Instagram oauth 流程

Instagram oauth flow in angularjs

我正在使用 angularJs 并提供一个按钮让用户授权到 instagram。

我可以通过传递 https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token 来测试我在 redirectUrl 中获取 accessToken。

问题是如何在 angularJs 按钮单击时调用此流程。目前我的情况如下:

html 授权给 Instagram

js

app.controller('AdminController', ['$scope', function($scope){
...
    this.authorizeIg = function(){
            console.log('start of authorizeIg implict flow');
            window.location.href = "https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token";
        };

以上将在身份验证后将我重定向到 redirect_url。所以,我不知道如何在函数中调用 url 并 return 返回包含 accessToken

的响应

单击一次按钮只会重定向网页以生成访问令牌,但不会保存它。 Instagram 没有 return 使用访问令牌的响应结果。

"https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token";

在angularJS中,在上面添加一个redirect_uri如:http://localhost/angularapp/:accessToken 会将您的应用程序重定向到此带有 link 的 URI,例如:http://localhost/angularapp/#access_token=ACCESS-TOKEN 成功验证。

您可以使用 angular 的 $routeParams 指令在应用程序中捕获此令牌。

$scope.token = $routeParams.accessToken 在您的 redirect_uri.

中明确定义