use of com.flickr4java.flickr.auth.AuthInterface in project data-transfer-project by google.
the class FlickrAuth method generateAuthData.
@Override
public AuthData generateAuthData(String callbackBaseUrl, String authCode, UUID jobId, AuthData initialAuthData, @Nullable String extra) throws IOException {
Preconditions.checkArgument(Strings.isNullOrEmpty(extra), "Extra data not expected");
Preconditions.checkNotNull(initialAuthData, "Earlier auth data not expected for Google flow");
AuthInterface authInterface = flickr.getAuthInterface();
Token token = fromAuthData(initialAuthData);
Token requestToken = authInterface.getAccessToken(token, new Verifier(authCode));
try {
authInterface.checkToken(requestToken);
return TokenSecretAuthData.create(requestToken.getToken(), requestToken.getSecret());
} catch (FlickrException e) {
throw new IOException("Problem verifying auth token", e);
}
}
use of com.flickr4java.flickr.auth.AuthInterface in project data-transfer-project by google.
the class FlickrAuth method generateAuthData.
@Override
public AuthData generateAuthData(IOInterface ioInterface) throws IOException {
AuthInterface authInterface = flickr.getAuthInterface();
Token token = authInterface.getRequestToken();
String url = authInterface.getAuthorizationUrl(token, Permission.WRITE);
String tokenKey = ioInterface.ask("Please enter the code from this authUrl: " + url);
Token requestToken = authInterface.getAccessToken(token, new Verifier(tokenKey));
try {
Auth auth = authInterface.checkToken(requestToken);
return toAuthData(requestToken);
} catch (FlickrException e) {
throw new IOException("Problem verifying auth token", e);
}
}
use of com.flickr4java.flickr.auth.AuthInterface in project data-transfer-project by google.
the class FlickrAuth method generateAuthUrl.
// online case
@Override
public AuthFlowInitiator generateAuthUrl(String callbackBaseUrl, UUID jobId) throws IOException {
AuthInterface authInterface = flickr.getAuthInterface();
Token token = authInterface.getRequestToken(callbackBaseUrl + "/callback1/flickr");
String url = authInterface.getAuthorizationUrl(token, serviceMode == ServiceMode.IMPORT ? Permission.WRITE : Permission.READ);
return AuthFlowInitiator.create(url, toAuthData(token));
}
use of com.flickr4java.flickr.auth.AuthInterface in project data-transfer-project by google.
the class FlickrAuthDataGenerator method generateConfiguration.
@Override
public AuthFlowConfiguration generateConfiguration(String callbackBaseUrl, String id) {
AuthInterface authInterface = flickr.getAuthInterface();
Token token = authInterface.getRequestToken(callbackBaseUrl + "/callback1/flickr");
String url = authInterface.getAuthorizationUrl(token, Permission.WRITE);
return new AuthFlowConfiguration(url, toAuthData(token));
}
use of com.flickr4java.flickr.auth.AuthInterface in project data-transfer-project by google.
the class FlickrAuthDataGenerator method generateAuthData.
@Override
public AuthData generateAuthData(String callbackBaseUrl, String authCode, String id, AuthData initialAuthData, String extra) {
Preconditions.checkArgument(Strings.isNullOrEmpty(extra), "Extra data not expected");
Preconditions.checkNotNull(initialAuthData, "Earlier auth data not expected for Flickr flow");
AuthInterface authInterface = flickr.getAuthInterface();
Token token = fromAuthData(initialAuthData);
Token requestToken = authInterface.getAccessToken(token, new Verifier(authCode));
try {
authInterface.checkToken(requestToken);
} catch (FlickrException e) {
logger.warn("Problem verifying auth token {}", e);
return null;
}
return new TokenSecretAuthData(requestToken.getToken(), requestToken.getSecret());
}
Aggregations