【问题标题】:How to get token from URL and redirect back to app after instagram authorization?如何在 Instagram 授权后从 URL 获取令牌并重定向回应用程序?
【发布时间】:2017-04-17 21:30:27
【问题描述】:

我用这个来授权:

Button loginBtn = (Button) findViewById(R.id.button);
    loginBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent viewIntent =
                    new Intent("android.intent.action.VIEW",
                            Uri.parse("https://api.instagram.com/oauth/authorize/?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=token"));
            startActivity(viewIntent);
        }
    });

用户登录并成功授权后,他会被重定向到 REDIRECT_URI,其中添加了类似http://your-redirect-uri#access_token=ACCESS-TOKEN 的令牌

我的问题是:

1) 当 instagram 只允许 REDIRECT_URI 具有 http:// or https:// 架构,因此我不能使用 myapp:// 方法时,如何将用户重定向回我的应用程序。

2) 如何将令牌从 URL 中检索回我的应用程序?

我知道以前曾发布过类似的问题,我阅读了数百个,但据我所知,似乎没有一个得到回答。

【问题讨论】:

    标签: java android oauth-2.0 instagram-api


    【解决方案1】:

    使用webview登录,使用webview onload事件读取access_token哈希片段

    【讨论】:

      猜你喜欢
      • 2020-11-02
      • 1970-01-01
      • 2022-06-27
      • 2016-02-25
      • 1970-01-01
      • 2022-07-20
      • 2020-03-24
      • 2020-07-21
      • 2020-12-26
      相关资源
      最近更新 更多