Error which i am getting:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized { "code" : 401, "errors" : [ { "domain" : "global", "location" : "Authorization", "locationType" : "header", "message" : "Invalid Credentials", "reason" : "authError" } ], "message" : "Invalid Credentials" } Below code, i am using:
GoogleCredential credential = new GoogleCredential.Builder() .setTransport(this.TRANSPORT).setJsonFactory(this.JSON_FACTORY) .setClientSecrets(Constants.CLIENT_ID, Constants.CLIENT_SECRET).build(); credential.setAccessToken(tokenResponse.getAccessToken()); credential.setAccessToken(tokenResponse.getRefreshToken()); Till here, i get Refresh token, Access Token, etc
Oauth2 userInfoService = new Oauth2.Builder(this.TRANSPORT, this.JSON_FACTORY, credential.getRequestInitializer()) .setApplicationName(Constants.APPLICATION_NAME).build(); It fails at below line: (Dont know, Why?)
Userinfo userInfo = userInfoService.userinfo().get().execute(); I searched on web, and i get very less examples of it and rare materials. Any body has any idea on it?
What am i doing wrong?