-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathapp.js
55 lines (41 loc) · 1.14 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//authClient.setCredentials({ access_token: 'abc123' });
var log4js = require("log4js");
var GoogleAuth = require('google-auth-library');
var google = require('googleapis');
var logger = log4js.getLogger();
var authClient = new google.auth.Compute();
if (authClient.createScopedRequired && authClient.createScopedRequired()) {
authClient = authClient.createScoped(['https://www.googleapis.com/auth/userinfo.email']);
}
var service = google.oauth2({ version: 'v2', auth: authClient });
service.userinfo.get(function(err, info) {
if (err) {
logger.error(err);
return;
}
logger.info(info.email);
});
const Storage = require('@google-cloud/storage');
const storage = new Storage({
projectId: 'your-project',
});
storage.getBuckets(function(err, buckets) {
if (!err) {
buckets.forEach(function(value){
logger.info(value.id);
});
}
});
const Pubsub = require('@google-cloud/pubsub');
const pubsub = Pubsub({
projectId: 'your-project'
});
pubsub.getTopics((err, topic) => {
if (err) {
logger.error(err);
return;
}
topic.forEach(function(entry) {
logger.info(entry.name);
});
});