Guest User

Untitled

a guest
Nov 16th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. static {
  2. try {
  3. DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR);
  4. HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
  5. } catch (Throwable t) {
  6. t.printStackTrace();
  7. }
  8. }
  9.  
  10.  
  11. private Credential authorize() throws IOException {
  12. // load client secrets
  13. GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(
  14. Thread.currentThread().getContextClassLoader().getResourceAsStream("credentials.json")));
  15. // set up authorization code flow
  16. GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY,
  17. clientSecrets, SCOPES).setDataStoreFactory(DATA_STORE_FACTORY).build();
  18. // authorize
  19. return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
  20. }
Add Comment
Please, Sign In to add comment