Android: 显示网页并让用户登录以获取 feedly 访问令牌

Android: display a web page and letting user login to get the feedly access token

我正在尝试编写一个 Android 应用来访问和向用户显示 Feedly 订阅。

为此,我需要 post 一个 URL 到 Feedly API 并在 return 中发回登录页面的 HTML 代码。

URL 例如 post:

https://sandbox7.feedly.com/v3/auth/auth?client_id=sandbox&redirect_uri=http%3A%2F%2Flocalhost&scope=https://cloud.feedly.com/subscriptions&response_type=code

在这里,我使用 http://localhost 作为重定向 URI,因为我没有为这个应用程序托管任何东西。

用户登录后,Feedly API 将代码重定向到 http://localhost

现在,我有两个问题: 1. Android上的登录网页不知道怎么显示。我该怎么做并让用户登录?为此目的的最佳做法是什么? 2. 如何获取作为参数发送回重定向 URI 的访问令牌?

对于第一个问题,也许我可以按照另一个问题中的建议使用 webview。 How to display a webpage in android?

但是我该如何将代码 return 发送到 redirect_uri?

谢谢。

我通过正确调用移动浏览器解决了这个问题 URL:

String url = "http://cloud.feedly.com/v3/auth/auth?client_id=xxxx&redirect_uri=myownuri%3A%2F%2F&scope=https://cloud.feedly.com/subscriptions&response_type=code";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
finish();

然后通过在清单文件中注册自定义 URI 来获取重定向的 URL:

<activity
    android:name=".BrowserActivity"
    android:label="Feedly Login" >
   <intent-filter>
        <data android:scheme="myownuri" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
</activity>

然后我在 activity 中解析返回的参数:

Uri data = this.getIntent().getData();
if (data != null && data.isHierarchical()) {
    String url = this.getIntent().getDataString();