【问题标题】:How to use redirect URI with OAuth2.0 and Box for my Android application?如何为我的 Android 应用程序使用带有 OAuth2.0 和 Box 的重定向 URI?
【发布时间】:2014-11-18 23:52:48
【问题描述】:

我有一个使用 Box sdk 的 Android 应用程序。 Box 功能已经被破坏了一段时间,因为我终于开始更新到最新版本的 sdk。当我尝试使用 OAuthActivity 对我的应用程序中的用户进行身份验证时,我被告知“错误:redirect_uri_missing”。

当我在 Box 开发人员页面上查看我的应用程序时,我看到它希望我在 OAuth2 参数部分输入重定向 uri。但是,尽管在寻找答案,但我对在这里输入什么感到非常困惑?

编辑:

基于下面的 API,我似乎可以使用下面的方法在没有设置重定向 uri 的情况下对 box 进行身份验证。但是,当我按如下方式使用它时,我得到:“错误:insecure_redirect_uri”。

OAuthActivity.createOAuthActivityIntent(activity, KEY, SECRET, false, "http://localhost");

/**
     * Create intent to launch OAuthActivity. Notes about redirect url parameter: If you already set redirect url in <a
     * href="https://cloud.app.box.com/developers/services">box dev console</a>, you should pass in the same redirect url or use null for redirect url. If you
     * didn't set it in box dev console, you should pass in a url. In case you don't have a redirect server you can simply use "http://localhost".
     * 
     * @param context
     *            context
     * @param clientId
     *            your box client id
     * @param clientSecret
     *            your box client secret
     * @param allowShowRedirectPage
     *            Whether you want to load/show redirected page after OAuth flow is done.
     * @param redirectUrl
     *            redirect url, if you already set redirect url in <a href="https://cloud.app.box.com/developers/services">box dev console</a>, leave this null
     *            or use the same url, otherwise this field is required. You can use "http://localhost" if you don't have a redirect server.
     * @return
     */
    public static Intent createOAuthActivityIntent(final Context context, final String clientId, final String clientSecret,
        final boolean allowShowRedirectPage, String redirectUrl)

【问题讨论】:

    标签: android box-api box boxapiv2


    【解决方案1】:

    抱歉,有些文档已经过时了。您应该使用 https://localhost 作为应用程序配置页面上的重定向 URI(可以找到 here)。我们不再允许不安全的重定向 URI,这意味着它们必须使用 HTTPS。为您的应用设置重定向 URI 后,您可以将 redirectUrl 参数留空。

    【讨论】:

      【解决方案2】:

      可以输入http://127.0.0.1https://127.0.0.1(环回地址)

      【讨论】:

        猜你喜欢
        • 2012-10-28
        • 2013-05-21
        • 2017-06-29
        • 1970-01-01
        • 2019-11-10
        • 1970-01-01
        • 2015-02-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多