コード例 #1
0
  // FLICKR AUTHENTICATION HELPER FUNCTIONS
  // Attempts to authneticate with a given token
  public void authenticateWithToken(String _token) {
    AuthInterface authInterface = flickr.getAuthInterface();

    // make sure the token is legit
    try {
      authInterface.checkToken(_token);
    } catch (Exception e) {
      println("Token is bad, getting a new one");
      getAuthentication();
      return;
    }

    auth = new Auth();

    RequestContext requestContext = RequestContext.getRequestContext();
    requestContext.setSharedSecret(secretKey);
    requestContext.setAuth(auth);

    auth.setToken(_token);
    auth.setPermission(Permission.WRITE);
    flickr.setAuth(auth);
    println("Authentication success");
  }