Skip to content

Improve service account code #731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions govcd/service_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,13 @@ func (sa *ServiceAccount) Authorize() error {
userDef = "provider"
}

endpoint := fmt.Sprintf("%s://%s/oauth/%s/device_authorization", client.VCDHREF.Scheme, client.VCDHREF.Host, userDef)
endpoint := client.rootVcdHref() + "/" + fmt.Sprintf(types.OpenApiEndpointServiceAccountAuthorization, userDef)
urlRef, err := url.ParseRequestURI(endpoint)
if err != nil {
return fmt.Errorf("error getting request url from %s: %s", urlRef.String(), err)
}

// Not an OpenAPI endpoint so hardcoding the Service Account minimal version
err = client.OpenApiPostUrlEncoded("37.0", urlRef, nil, data, &sa.authParams, nil)
err = client.OpenApiPostUrlEncoded(client.APIVersion, urlRef, nil, data, &sa.authParams, nil)
if err != nil {
return fmt.Errorf("error authorizing service account: %s", err)
}
Expand Down
7 changes: 4 additions & 3 deletions types/v56/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,10 @@ const (
OpenApiEndpointAlbEdgeGateway = "edgeGateways/%s/loadBalancer"

// OpenApiEndpointServiceAccountGrant is needed for granting a Service Account
OpenApiEndpointServiceAccountGrant = "deviceLookup/grant"
OpenApiEndpointTokens = "tokens/"
OpenApiEndpointServiceAccounts = "serviceAccounts/"
OpenApiEndpointServiceAccountGrant = "deviceLookup/grant"
OpenApiEndpointTokens = "tokens/"
OpenApiEndpointServiceAccounts = "serviceAccounts/"
OpenApiEndpointServiceAccountAuthorization = "oauth/%s/device_authorization"

// OpenApiEndpointVgpuProfile is used to query vGPU profiles
OpenApiEndpointVgpuProfile = "vgpuProfiles"
Expand Down
Loading