GetCredentials returns the service account credentials JSON
()
| 138 | |
| 139 | // GetCredentials returns the service account credentials JSON |
| 140 | func GetCredentials() ([]byte, error) { |
| 141 | if currentProfile == nil { |
| 142 | return nil, fmt.Errorf("no profile configured. Run 'playconsole-cli auth login' first") |
| 143 | } |
| 144 | |
| 145 | // Try base64 encoded credentials first |
| 146 | if currentProfile.CredentialsB64 != "" { |
| 147 | data, err := base64.StdEncoding.DecodeString(currentProfile.CredentialsB64) |
| 148 | if err != nil { |
| 149 | return nil, fmt.Errorf("failed to decode credentials: %w", err) |
| 150 | } |
| 151 | return data, nil |
| 152 | } |
| 153 | |
| 154 | // Try credentials file |
| 155 | if currentProfile.CredentialsPath != "" { |
| 156 | data, err := os.ReadFile(currentProfile.CredentialsPath) |
| 157 | if err != nil { |
| 158 | return nil, fmt.Errorf("failed to read credentials file: %w", err) |
| 159 | } |
| 160 | return data, nil |
| 161 | } |
| 162 | |
| 163 | return nil, fmt.Errorf("no credentials configured for profile '%s'. Run 'playconsole-cli auth login' first", currentProfile.Name) |
| 164 | } |
| 165 | |
| 166 | // SetDebug sets debug mode |
| 167 | func SetDebug(d bool) { |
no outgoing calls
no test coverage detected