I want to authorize user from my app, I am following some example found on internet (http://www.programcreek.com/java-api-examples/index.php?api=org.scribe.model.Token):
public static void auth() throws IOException, FlickrException {
Properties properties;
InputStream in=null;
try {
in=AuthExample.class.getResourceAsStream("/setup.properties");
properties=new Properties();
properties.load(in);
}
finally {
IOUtilities.close(in);
}
Flickr flickr=new Flickr(properties.getProperty("apiKey"),properties.getProperty("secret"),new REST());
Flickr.debugStream=false;
AuthInterface authInterface=flickr.getAuthInterface();
Scanner scanner=new Scanner(System.in);
Token token=authInterface.getRequestToken();
System.out.println("token: " + token);
String url=authInterface.getAuthorizationUrl(token,Permission.READ);
System.out.println("Follow this URL to authorise yourself on Flickr");
System.out.println(url);
System.out.println("Paste in the token it gives you:");
System.out.print(">>");
String tokenKey=scanner.nextLine();
Token requestToken=authInterface.getAccessToken(token,new Verifier(tokenKey));
System.out.println("Authentication success");
Auth auth=authInterface.checkToken(requestToken);
System.out.println("Token: " + requestToken.getToken());
System.out.println("nsid: " + auth.getUser().getId());
System.out.println("Realname: " + auth.getUser().getRealName());
System.out.println("Username: " + auth.getUser().getUsername());
System.out.println("Permission: " + auth.getPermission().getType());
}
I am using webview, scribe and Flickr4Java for run URL which provide a code, authenticate and web view shows me a code, which I must pass to my app, but I can't understand how to retrieve this code from webview, and pass to tokenKey.
I am added onpageFinished and print URL which me give:
06-12 13:03:55.266 E/NEW﹕ uri is: https://m.flickr.com/services/oauth/authorize?oauth_token=72157654039925698-81abc00d035f5da0&perms=write
06-12 13:03:55.601 W/BindingManager﹕ Cannot call determinedVisibility() - never saw a connection for the pid: 4581
06-12 13:03:56.166 E/NEW﹕ uri is: https://m.flickr.com/#/services/oauth/authorize/_QM_oauth_token_IS_72157654039925698-81abc00d035f5da0_AND_perms_IS_write
06-12 13:03:56.476 W/BindingManager﹕ Cannot call determinedVisibility() - never saw a connection for the pid: 4581
06-12 13:03:56.476 E/NEW﹕ uri is: https://m.flickr.com/#/services/oauth/authorize/_QM_oauth_token_IS_72157654039925698-81abc00d035f5da0_AND_perms_IS_write
06-12 13:04:00.411 W/BindingManager﹕ Cannot call determinedVisibility() - never saw a connection for the pid: 4581
06-12 13:04:00.416 E/NEW﹕ uri is: https://m.flickr.com/#/#
Finaly, i found an answer (this provide a calback url:
token = authInterface.getRequestToken("your calback url");
), the code for auth for someone is: