Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Skip auth when options empty
Browse files Browse the repository at this point in the history
  • Loading branch information
BirknerAlex committed Feb 7, 2023
1 parent 3fc91b0 commit 5391e0a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pkg/gpcloud/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@ func NewClient(authOptions AuthOptions, options ...grpc.DialOption) (*Client, er
// User Agent
options = append(options, grpc.WithUserAgent(fmt.Sprintf("GPCloud Golang Client [%s]", Version)))

auth, err := NewAuth(&authOptions)
if err != nil {
return nil, err
// Default auth loader
if authOptions.ClientID != "" &&
authOptions.ClientSecret != "" &&
authOptions.Username != "" &&
authOptions.Password != "" {
auth, err := NewAuth(&authOptions)
if err != nil {
return nil, err
}
// Access Token
options = append(options, grpc.WithPerRPCCredentials(auth))
}
// Access Token
options = append(options, grpc.WithPerRPCCredentials(auth))

clientConn, err := grpc.Dial(DefaultEndpoint, options...)
if err != nil {
Expand Down

0 comments on commit 5391e0a

Please sign in to comment.