2013-12-08 17:37:36 -05:00
|
|
|
package googlecompute
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
// clientSecrets represents the client secrets of a GCE service account.
|
|
|
|
type clientSecrets struct {
|
|
|
|
Web struct {
|
|
|
|
AuthURI string `json:"auth_uri"`
|
|
|
|
ClientEmail string `json:"client_email"`
|
|
|
|
ClientId string `json:"client_id"`
|
|
|
|
TokenURI string `json:"token_uri"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// loadClientSecrets loads the GCE client secrets file identified by path.
|
|
|
|
func loadClientSecrets(path string) (*clientSecrets, error) {
|
|
|
|
var cs *clientSecrets
|
|
|
|
secretBytes, err := ioutil.ReadFile(path)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2013-12-12 20:54:48 -05:00
|
|
|
|
2013-12-08 17:37:36 -05:00
|
|
|
err = json.Unmarshal(secretBytes, &cs)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2013-12-12 20:54:48 -05:00
|
|
|
|
2013-12-08 17:37:36 -05:00
|
|
|
return cs, nil
|
|
|
|
}
|