Skip to content

Commit

Permalink
Fix the keyfile unmarshal error (#339)
Browse files Browse the repository at this point in the history
---

*Motivation*

Fix the keyfile unmarshal error:
```
open test_credential.json: unsupported format
```
  • Loading branch information
zymap committed Aug 3, 2020
1 parent 27a9c06 commit 570d5ce
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
8 changes: 0 additions & 8 deletions oauth2/client_credentials_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ package oauth2

import (
"encoding/json"
"fmt"
"io/ioutil"
)

const (
KeyFileTypeServiceAccount = "sn_service_account"
)

type KeyFileProvider struct {
KeyFile string
}
Expand Down Expand Up @@ -58,9 +53,6 @@ func (k *KeyFileProvider) GetClientCredentials() (*KeyFile, error) {
if err != nil {
return nil, err
}
if v.Type != KeyFileTypeServiceAccount {
return nil, fmt.Errorf("open %s: unsupported format", k.KeyFile)
}

return &v, nil
}
2 changes: 1 addition & 1 deletion pulsar/client_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func mockKeyFile(server string) (string, error) {
return "", err
}
_, err = kf.WriteString(fmt.Sprintf(`{
"type":"sn_service_account",
"type":"resource",
"client_id":"client-id",
"client_secret":"client-secret",
"client_email":"oauth@test.org",
Expand Down
2 changes: 1 addition & 1 deletion pulsar/internal/auth/oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func mockKeyFile(server string) (string, error) {
return "", err
}
_, err = kf.WriteString(fmt.Sprintf(`{
"type":"sn_service_account",
"type":"resource",
"client_id":"client-id",
"client_secret":"client-secret",
"client_email":"oauth@test.org",
Expand Down

0 comments on commit 570d5ce

Please sign in to comment.