About OAuth Authentication

Asked 1 years ago, Updated 1 years ago, 51 views

I'm a beginner in Android development.

I have a question about OAuth authentication.
Currently, we are developing to the point where when you press the authentication button on the screen, it goes to the authentication screen on Twitter (this is a practice application).
I tried coding in my own way, but when I press "Authentication", an error occurs and the application drops.I also tried debacking, but I don't know why.

Could you please let me know if anyone knows the cause?

The following information:
My library:
commons-codec-1.5.jar
signpost-core-1.2.1.1.jar
signpost-commonshttp4-1.2.1.jar
Source Code:
It is listed on the following page.
https://goo.gl/UtIITo
Logcat Error Tabs During Debugging:
src=
<Note>
twitter.java:57 is
in Main Activity startActivity (newIntent(Intent.ACTION_VIEW, Uri.parse(authUrl)));

Error Details:
"When I press the ""Authentication"" button on the app, the comment ""I have a problem, so I will close the app"" will soon appear, and the app will drop."
debug details:
。 "Regarding ""debug"", we tried the debug tool that comes standard with Android Studio and reviewed the error areas in LogCat."I don't use BreakPoint in particular.

Thank you for your cooperation

android java oauth

2022-09-30 16:02

1 Answers

Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent {act=android.intent.action.VIEW dat=}

The error indicates that the corresponding Activity cannot be found for the specified Intent, but the dat value appears to be empty.If you read the corresponding source code...

public void onClickBtnLogin(View v){
    String authUrl="";
    try{
        authUrl=oauthProvider.retrieveRequestToken(oauthConsumer, AppConstants.CALLBACK_URL);
    } catch(OAuthMessageSignerExceptione){
        Log.e(getClass().getSimpleName(), "Twitter OAuth Error", e);
    } catch(OAuthNotAuthorizedExceptione){
        Log.e(getClass().getSimpleName(), "Twitter OAuth Error", e);
    } catch(OAuthExpectationFailedExceptione){
        Log.e(getClass().getSimpleName(), "Twitter OAuth Error", e);
    } catch(OAuthCommunicationException){
        Log.e(getClass().getSimpleName(), "Twitter OAuth Error", e);
    }

    startActivity(newIntent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
}

Even if oauthProvider.retrieveRequestToken() fails, startActivity(newIntent(...)) will run.In this case, authUrl is an empty string, so it may be an opening error.

If authUrl cannot be retrieved, it is necessary not to startActivity.

Anyway, check to see if authUrl is the correct URL.


2022-09-30 16:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.