Skip to content

Commit 3fd60e5

Browse files
Add support for scopes
Defaults to https://www.googleapis.com/auth/cloud-platform
1 parent acf4ea8 commit 3fd60e5

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

internal/google_access_token/resource_func.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import (
1414

1515
func read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
1616

17-
creds, err := google.FindDefaultCredentials(context.TODO())
17+
scopes := d.Get("scopes").([]string)
18+
19+
creds, err := google.FindDefaultCredentials(context.TODO(), scopes...)
1820
if err != nil {
1921
return diag.FromErr(err)
2022
}

internal/google_access_token/resource_schema.go

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import (
77
func Resource() *schema.Resource {
88
return &schema.Resource{
99
Schema: map[string]*schema.Schema{
10+
"scopes": {
11+
Type: schema.TypeList,
12+
Elem: &schema.Schema{
13+
Type: schema.TypeString,
14+
},
15+
Default: []string{"https://www.googleapis.com/auth/cloud-platform"},
16+
},
1017
"access_token": {
1118
Type: schema.TypeString,
1219
Computed: true,

0 commit comments

Comments
 (0)