Search code examples
google-glassgoogle-mirror-api

The method execute() is undefined for the type Mirror.Accounts.Insert


I am creating a server side Dynamic Web Project using Java and Eclipse IDE for Google Glass Mirror API. In my web project I have a lib folder under WEB-INF

In the lib folder i have added the following .jar files

  • google-api-client-1.18.0-rc-sources.jar

  • google-api-services-mirror-v1-rev66-1.19.0.jar

  • google-collections-1.0-rc2.jar

  • google-http-client-1.18.0-rc.jar

  • google-http-client-jackson-1.19.0.jar

My server side code is

 @SuppressWarnings("serial")
    public class GlassAuthenticateUser extends HttpServlet{

public static Mirror getMirrorService() throws GeneralSecurityException,
IOException, URISyntaxException {
    HttpTransport httpTransport = new NetHttpTransport();
    JacksonFactory jsonFactory = new JacksonFactory();

    GoogleCredential credential = new GoogleCredential.Builder()
    .setTransport(httpTransport)
    .setJsonFactory(jsonFactory)
    .setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
    .setServiceAccountScopes(MIRROR_ACCOUNT_SCOPES)
    .setServiceAccountPrivateKeyFromP12File(
            new java.io.File(SERVICE_ACCOUNT_PKCS12_FILE_PATH))
            .build();
    Mirror service = new Mirror.Builder(httpTransport, jsonFactory, null)
    .setHttpRequestInitializer(credential).build();
    return service;
}

public static void createAccount(Mirror mirror, String userToken, String accountName,
        String authTokenType, String authToken) {
    try {
        Account account = new Account();
        List<AuthToken> authTokens = Lists.newArrayList(
                new AuthToken().setType(authTokenType).setAuthToken(authToken));
        account.setAuthTokens(authTokens);
        mirror.accounts().insert(
                userToken, ACCOUNT_TYPE, accountName, account).execute();
    } catch (IOException e) {
        e.printStackTrace();
    }
}


public void doGet(HttpServletRequest request,HttpServletResponse response)
            throws ServletException, IOException{

     //TO DO             
     }
}

}

I am getting the following error

The method execute() is undefined for the type Mirror.Accounts.Insert

Why is that so? I have download the latest Google API java client and used them in my project. However, it is unable to also resolve the GoogleCredential class

Can anyone suggest which .jar files should I be adding to resolve this issue?


Solution

  • It looks like you have the source jar for google-api-client-1.18.0-rc, when you need the class jar. You should be able to download the latest bundle from https://code.google.com/p/google-api-java-client/wiki/Downloads?tm=2 and then extracting google-api-java-client/libs/google-api-client-1.18.0-rc.jar from the downloaded zip file.