Skip to content

Commit 40a0f74

Browse files
authored
Merge pull request googleworkspace#90 from diminishedprime/master
Update data-studio examples to use new Apps Script builder.
2 parents bb01146 + 24b4274 commit 40a0f74

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed

data-studio/auth.gs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
* @return {object} The Auth type.
2121
*/
2222
function getAuthType() {
23-
return {
24-
type: 'OAUTH2'
25-
};
23+
var cc = DataStudioApp.createCommunityConnector();
24+
return cc.newAuthTypeResponse()
25+
.setAuthType(cc.AuthType.OAUTH2)
26+
.build();
2627
}
2728
// [END apps_script_data_studio_get_auth_type_oauth2]
2829

@@ -32,10 +33,11 @@ function getAuthType() {
3233
* @return {object} The Auth type.
3334
*/
3435
function getAuthType() {
35-
return {
36-
type: 'USER_PASS',
37-
helpUrl: 'https://www.example.org/connector-auth-help'
38-
};
36+
var cc = DataStudioApp.createCommunityConnector();
37+
return cc.newAuthTypeResponse()
38+
.setAuthType(cc.AuthType.USER_PASS)
39+
.setHelpUrl('https://www.example.org/connector-auth-help')
40+
.build();
3941
}
4042
// [END apps_script_data_studio_get_auth_type_user_pass]
4143

@@ -45,10 +47,11 @@ function getAuthType() {
4547
* @return {object} The Auth type.
4648
*/
4749
function getAuthType() {
48-
return {
49-
type: 'USER_TOKEN',
50-
helpUrl: 'https://www.example.org/connector-auth-help'
51-
};
50+
var cc = DataStudioApp.createCommunityConnector();
51+
return cc.newAuthTypeResponse()
52+
.setAuthType(cc.AuthType.USER_TOKEN)
53+
.setHelpUrl('https://www.example.org/connector-auth-help')
54+
.build();
5255
}
5356
// [END apps_script_data_studio_get_auth_type_user_token]
5457

@@ -58,10 +61,11 @@ function getAuthType() {
5861
* @return {object} The Auth type.
5962
*/
6063
function getAuthType() {
61-
return {
62-
type: 'KEY',
63-
helpUrl: 'https://www.example.org/connector-auth-help'
64-
};
64+
var cc = DataStudioApp.createCommunityConnector();
65+
return cc.newAuthTypeResponse()
66+
.setAuthType(cc.AuthType.KEY)
67+
.setHelpUrl('https://www.example.org/connector-auth-help')
68+
.build();
6569
}
6670
// [END apps_script_data_studio_get_auth_type_key]
6771

@@ -71,9 +75,10 @@ function getAuthType() {
7175
* @return {object} The Auth type.
7276
*/
7377
function getAuthType() {
74-
return {
75-
type: 'NONE'
76-
};
78+
var cc = DataStudioApp.createCommunityConnector();
79+
return cc.newAuthTypeResponse()
80+
.setAuthType(cc.AuthType.NONE)
81+
.build();
7782
}
7883
// [END apps_script_data_studio_get_auth_type_none]
7984

data-studio/build.gs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ function getData(request) {
148148
* @return {object} The auth type.
149149
*/
150150
function getAuthType() {
151-
var response = {type: 'NONE'};
152-
return response;
151+
var cc = DataStudioApp.createCommunityConnector();
152+
return cc.newAuthTypeResponse()
153+
.setAuthType(cc.AuthType.NONE)
154+
.build();
153155
}
154156
// [END apps_script_data_studio_build_get_auth_type]

data-studio/caas.gs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ function getData(request) {
147147
* @return {object} The auth type.
148148
*/
149149
function getAuthType() {
150-
return {type: 'NONE'};
150+
var cc = DataStudioApp.createCommunityConnector();
151+
return cc.newAuthTypeResponse()
152+
.setAuthType(cc.AuthType.NONE)
153+
.build();
151154
}
152155
// [END apps_script_data_studio_caas_example]

0 commit comments

Comments
 (0)