Android AppAuth、重定向URI、Stackexchange、Instagram API

Android AppAuth、重定向URI、Stackexchange、Instagram API,android,oauth-2.0,instagram-api,stackexchange-api,appauth,Android,Oauth 2.0,Instagram Api,Stackexchange Api,Appauth,我想进行OAuth2授权 我使用:实现 我研究过很多例子(谷歌代码实验室、AppAuth等) 我也学习过 我想把这个应用到和 我只了解一件事:自定义重定向URI,如“com.example.auth:/oauth2callback”,它不再适用于SE和Instagram 我尝试了不同的方案,结果都是一样的 我的问题是接收活动没有启动。 有人能为SE或Insta OAuth API指定正确的重定向URI设置(适用于Android应用程序和AppAuth库吗? 清单(我在这里尝试了许多选项) <

我想进行OAuth2授权

我使用:实现

我研究过很多例子(谷歌代码实验室、AppAuth等)

我也学习过

我想把这个应用到和

我只了解一件事:自定义重定向URI,如“com.example.auth:/oauth2callback”,它不再适用于SE和Instagram

我尝试了不同的方案,结果都是一样的

我的问题是接收活动没有启动。

有人能为SE或Insta OAuth API指定正确的重定向URI设置(适用于Android应用程序和AppAuth库吗?

清单(我在这里尝试了许多选项)

<activity android:name="net.openid.appauth.RedirectUriReceiverActivity"
tools:node="replace">
<intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>

                <data android:scheme="com.example.auth"
                data android:scheme="https"
                 android:host="stackexchange.com"
                 android:path="/oauth/login_success"/>

            </intent-filter>
        </activity>
private static final String AUTH_ENDPOINT = "https://stackexchange.com/oauth/dialog";
    private static final String TOKEN_ENDPOINT = "https://stackexchange.com/oauth/access_token";
    private static final String CLIENT_ID = "123";
    //private static final String REDIRECT_URI = "com.example.auth:/oauth2callback";
    //private static final String REDIRECT_URI = "https://stackexchange.com/oauth/login_success"; //  com.example.auth://oauth/login_success
    private static final String REDIRECT_URI = "com.example.auth://oauth/login_success";
    private static final String SCOPES_AUTH = "no_expiry read_inbox";

// Authorization service configuration
            AuthorizationServiceConfiguration serviceConfiguration = new AuthorizationServiceConfiguration(
                    Uri.parse(AUTH_ENDPOINT) /* auth endpoint  https://tools.ietf.org/html/rfc6749#section-3.1 */,
                    Uri.parse(TOKEN_ENDPOINT) /* token endpoint https://tools.ietf.org/html/rfc6749#section-3.2 */,
                    null /* (optional) registration endpoint https://tools.ietf.org/html/rfc7591#section-3 */
            );
// Obtaining an authorization code
            Uri redirectUri = Uri.parse(REDIRECT_URI);
            AuthorizationRequest.Builder builder = new AuthorizationRequest.Builder(
                    serviceConfiguration,
                    CLIENT_ID,
                    ResponseTypeValues.CODE, // the response_type value: we want a code
                    redirectUri
            );
            builder.setScopes(SCOPES_AUTH);
            AuthorizationRequest request = builder.build();

            Context context = view.getContext();

            // do Authorization
            AuthorizationService authorizationService = new AuthorizationService(context);

            Intent postAuthorizationIntent = new Intent(view.getContext(), MainActivity.class);
            postAuthorizationIntent.setAction(HANDLE_AUTHORIZATION_RESPONSE);
            PendingIntent pendingIntent = PendingIntent.getActivity(context, request.hashCode(), postAuthorizationIntent, 0);
authorizationService.performAuthorizationRequest(request, pendingIntent);