use of oauth.signpost.exception.OAuthNotAuthorizedException in project twitterdroid by fbrunel.
the class ConfigActivity method onCreate.
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
try {
String authURL = provider.retrieveRequestToken(consumer, CALLBACK_URL);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authURL)));
} catch (OAuthMessageSignerException e) {
e.printStackTrace();
} catch (OAuthNotAuthorizedException e) {
e.printStackTrace();
} catch (OAuthExpectationFailedException e) {
e.printStackTrace();
} catch (OAuthCommunicationException e) {
e.printStackTrace();
}
finish();
}
use of oauth.signpost.exception.OAuthNotAuthorizedException in project data-transfer-project by google.
the class SmugMugAuth method generateAuthData.
@Override
public AuthData generateAuthData(IOInterface ioInterface) throws IOException {
// As per details: https://api.smugmug.com/api/v2/doc/tutorial/authorization.html
// and example:
// http://stackoverflow.com/questions/15194182/examples-for-oauth1-using-google-api-java-oauth
// Google library puts signature in header and not in request, see https://oauth.net/1/
OAuthConsumer consumer = new GoogleOAuthConsumer(appCredentials.key(), appCredentials.secret());
String permissions = (serviceMode == ServiceMode.EXPORT) ? "Read" : "Add";
OAuthProvider provider = new DefaultOAuthProvider("https://secure.smugmug.com/services/oauth/1.0a/getRequestToken", "https://secure.smugmug.com/services/oauth/1.0a/getAccessToken", "https://secure.smugmug.com/services/oauth/1.0a/authorize?Access=Full&Permissions=" + permissions);
String authUrl;
try {
authUrl = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);
} catch (OAuthMessageSignerException | OAuthNotAuthorizedException | OAuthExpectationFailedException | OAuthCommunicationException e) {
throw new IOException("Couldn't generate authUrl", e);
}
String code = ioInterface.ask("Please visit: " + authUrl + " and enter code:");
try {
provider.retrieveAccessToken(consumer, code.trim());
} catch (OAuthMessageSignerException | OAuthNotAuthorizedException | OAuthExpectationFailedException | OAuthCommunicationException e) {
throw new IOException("Couldn't authorize", e);
}
return TokenSecretAuthData.create(consumer.getToken(), consumer.getTokenSecret());
}
Aggregations