Download Jar. Uses 4337K of libraries. Click here for Pure Java version (2875L/17K).
1 | ifndef NoLib1400401 |
2 | lib 1400401 |
3 | endifndef |
4 | |
5 | import com.google.api.client.googleapis.auth.oauth2.*; |
6 | |
7 | import com.google.api.client.auth.oauth2.Credential; |
8 | import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp; |
9 | import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver; |
10 | import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow; |
11 | import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets; |
12 | import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; |
13 | import com.google.api.client.http.javanet.NetHttpTransport; |
14 | import com.google.api.client.http.HttpTransport; |
15 | import com.google.api.client.json.JsonFactory; |
16 | import com.google.api.client.json.jackson2.JacksonFactory; |
17 | |
18 | sclass GoogleAccess { |
19 | GoogleCredential credential; |
20 | |
21 | simplyCached HttpTransport transport() ctex { |
22 | ret GoogleNetHttpTransport.newTrustedTransport(); |
23 | } |
24 | |
25 | simplyCached JsonFactory jsonFactory() ctex { |
26 | ret JacksonFactory.getDefaultInstance(); |
27 | } |
28 | |
29 | simplyCached GoogleClientSecrets clientSecrets() ctex { |
30 | temp InputStream in = newFileInputStream(javaxSecretDir("google-botcompany-credentials.json")); |
31 | ret GoogleClientSecrets.load(jsonFactory(), new InputStreamReader(in)); |
32 | } |
33 | |
34 | GoogleCredential credentialFromTokens(S accessToken, S refreshToken) { |
35 | ret credential = new GoogleCredential.Builder() |
36 | .setTransport(transport()) |
37 | .setJsonFactory(jsonFactory()) |
38 | .setClientSecrets(clientSecrets()) |
39 | .build() |
40 | .setAccessToken(accessToken) |
41 | .setRefreshToken(refreshToken); |
42 | } |
43 | |
44 | GoogleCredential credentialFromJavaXSecret() ctex { |
45 | ret GoogleCredential.fromStream( |
46 | fileInputStream(assertFileExists(javaxSecretDir("google-access.json"))); |
47 | } |
48 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1028553 |
Snippet name: | GoogleAccess |
Eternal ID of this version: | #1028553/8 |
Text MD5: | b7c2576061a3d8edd62a35065b05e7d7 |
Transpilation MD5: | ec19ad2869517378265769102dd4329d |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-01-14 02:58:46 |
Source code size: | 1819 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 306 / 1145 |
Version history: | 7 change(s) |
Referenced in: | [show references] |