oauth.signpost.exception.OAuthNotAuthorizedException Java Examples
The following examples show how to use
oauth.signpost.exception.OAuthNotAuthorizedException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OAuthInteractorTest.java From Forage with Mozilla Public License 2.0 | 6 votes |
@Test public void retrieveAccessToken_success() throws OAuthCommunicationException, OAuthExpectationFailedException, OAuthNotAuthorizedException, OAuthMessageSignerException { Uri uri = mock(Uri.class); String verifier = "some verifier"; when(uri.getQueryParameter(OAuth.OAUTH_VERIFIER)).thenReturn(verifier); String userTokenString = "some token"; when(okHttpOAuthConsumer.getToken()).thenReturn(userTokenString); String userTokenSecretString = "some secret token"; when(okHttpOAuthConsumer.getTokenSecret()).thenReturn(userTokenSecretString); TestSubscriber testSubscriber = new TestSubscriber(); oAuthInteractor.retrieveAccessToken(uri) .subscribe(testSubscriber); testSubscriber.assertCompleted(); verify(okHttpOAuthProvider, times(1)).retrieveAccessToken(okHttpOAuthConsumer, verifier); verify(userToken, times(1)).set(userTokenString); verify(userTokenSecret, times(1)).set(userTokenSecretString); }
Example #2
Source File: OBPRestClient.java From Hello-OBP-OAuth1.0a-Android with Apache License 2.0 | 6 votes |
public static String getAuthoriseAppUrl(Context context) throws OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException { /** * You will want to set customProtocol to something unique to avoid * having Android give the user more than one app to pick from to handle * the oauth callback. A good option would be to use something derived * from your package name. */ String customProtocol = context.getResources().getString( R.string.customAppProtocol); return provider.retrieveRequestToken(consumer, customProtocol + "://oauth"); }
Example #3
Source File: OAuthInteractorTest.java From Forage with Mozilla Public License 2.0 | 5 votes |
@Test public void retrieveRequestToken_success() throws OAuthCommunicationException, OAuthExpectationFailedException, OAuthNotAuthorizedException, OAuthMessageSignerException { String token = "some token"; when(okHttpOAuthProvider.retrieveRequestToken(any(), anyString())).thenReturn(token); TestSubscriber<String> testSubscriber = new TestSubscriber<>(); oAuthInteractor.retrieveRequestToken() .subscribe(testSubscriber); testSubscriber.assertValue(token); verify(okHttpOAuthProvider, times(1)).retrieveRequestToken(okHttpOAuthConsumer, ApiConstants.OAUTH_CALLBACK); }
Example #4
Source File: OAuthInteractorTest.java From Forage with Mozilla Public License 2.0 | 5 votes |
@Test public void retrieveRequestToken_error() throws OAuthCommunicationException, OAuthExpectationFailedException, OAuthNotAuthorizedException, OAuthMessageSignerException { Throwable throwable = new RuntimeException(); when(okHttpOAuthProvider.retrieveRequestToken(any(), anyString())).thenThrow(throwable); TestSubscriber<String> testSubscriber = new TestSubscriber<>(); oAuthInteractor.retrieveRequestToken() .subscribe(testSubscriber); testSubscriber.assertError(throwable); verify(okHttpOAuthProvider, times(1)).retrieveRequestToken(okHttpOAuthConsumer, ApiConstants.OAUTH_CALLBACK); }
Example #5
Source File: OAuthInteractorTest.java From Forage with Mozilla Public License 2.0 | 5 votes |
@Test public void retrieveAccessToken_error() throws OAuthCommunicationException, OAuthExpectationFailedException, OAuthNotAuthorizedException, OAuthMessageSignerException { Uri uri = mock(Uri.class); when(uri.getQueryParameter(OAuth.OAUTH_VERIFIER)).thenReturn(null); TestSubscriber testSubscriber = new TestSubscriber(); oAuthInteractor.retrieveAccessToken(uri) .subscribe(testSubscriber); // We don't really care what the error is just that we have one // Hacky way to see if there is an error (terminal event) but not success (completion) testSubscriber.assertTerminalEvent(); testSubscriber.assertNotCompleted(); }
Example #6
Source File: OAuth.java From restcommander with Apache License 2.0 | 5 votes |
private Error(OAuthException exception) { this.exception = exception; if (this.exception instanceof OAuthMessageSignerException) { this.type = Type.MESSAGE_SIGNER; } else if (this.exception instanceof OAuthNotAuthorizedException) { this.type = Type.NOT_AUTHORIZED; } else if (this.exception instanceof OAuthExpectationFailedException) { this.type = Type.EXPECTATION_FAILED; } else if (this.exception instanceof OAuthCommunicationException) { this.type = Type.COMMUNICATION; } else { this.type = Type.OTHER; } this.details = exception.getMessage(); }