Search in sources :

Example 1 with AuthInterface

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);
    }
}
Also used : AuthInterface(com.flickr4java.flickr.auth.AuthInterface) FlickrException(com.flickr4java.flickr.FlickrException) Token(org.scribe.model.Token) IOException(java.io.IOException) Verifier(org.scribe.model.Verifier)

Example 2 with AuthInterface

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);
    }
}
Also used : AuthInterface(com.flickr4java.flickr.auth.AuthInterface) FlickrException(com.flickr4java.flickr.FlickrException) Auth(com.flickr4java.flickr.auth.Auth) Token(org.scribe.model.Token) IOException(java.io.IOException) Verifier(org.scribe.model.Verifier)

Example 3 with AuthInterface

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));
}
Also used : AuthInterface(com.flickr4java.flickr.auth.AuthInterface) Token(org.scribe.model.Token)

Example 4 with AuthInterface

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));
}
Also used : AuthFlowConfiguration(org.dataportabilityproject.spi.gateway.types.AuthFlowConfiguration) AuthInterface(com.flickr4java.flickr.auth.AuthInterface) Token(org.scribe.model.Token)

Example 5 with AuthInterface

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());
}
Also used : AuthInterface(com.flickr4java.flickr.auth.AuthInterface) TokenSecretAuthData(org.dataportabilityproject.types.transfer.auth.TokenSecretAuthData) FlickrException(com.flickr4java.flickr.FlickrException) Token(org.scribe.model.Token) Verifier(org.scribe.model.Verifier)

Aggregations

AuthInterface (com.flickr4java.flickr.auth.AuthInterface)5 Token (org.scribe.model.Token)5 FlickrException (com.flickr4java.flickr.FlickrException)3 Verifier (org.scribe.model.Verifier)3 IOException (java.io.IOException)2 Auth (com.flickr4java.flickr.auth.Auth)1 AuthFlowConfiguration (org.dataportabilityproject.spi.gateway.types.AuthFlowConfiguration)1 TokenSecretAuthData (org.dataportabilityproject.types.transfer.auth.TokenSecretAuthData)1