Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static {
- try {
- DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR);
- HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
- private Credential authorize() throws IOException {
- // load client secrets
- GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(
- Thread.currentThread().getContextClassLoader().getResourceAsStream("credentials.json")));
- // set up authorization code flow
- GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY,
- clientSecrets, SCOPES).setDataStoreFactory(DATA_STORE_FACTORY).build();
- // authorize
- return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
- }
Add Comment
Please, Sign In to add comment