forked from remote/oauth2
oauth2/google: ConfigFromJSON should support the installed app credentials
client_credentials.json may contain credentials for the installed applications. Populate the Config depending on what's available in the JSON key. Change-Id: I47f494f1c31967a920fe557a9e8c1c4652943c4e Reviewed-on: https://go-review.googlesource.com/7250 Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
@@ -24,6 +24,13 @@ var webJSONKey = []byte(`
|
||||
}
|
||||
}`)
|
||||
|
||||
var installedJSONKey = []byte(`{
|
||||
"installed": {
|
||||
"client_id": "222-installed.apps.googleusercontent.com",
|
||||
"redirect_uris": ["https://www.example.com/oauth2callback"]
|
||||
}
|
||||
}`)
|
||||
|
||||
func TestConfigFromJSON(t *testing.T) {
|
||||
conf, err := ConfigFromJSON(webJSONKey, "scope1", "scope2")
|
||||
if err != nil {
|
||||
@@ -48,3 +55,13 @@ func TestConfigFromJSON(t *testing.T) {
|
||||
t.Errorf("TokenURL = %q; want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigFromJSON_Installed(t *testing.T) {
|
||||
conf, err := ConfigFromJSON(installedJSONKey)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if got, want := conf.ClientID, "222-installed.apps.googleusercontent.com"; got != want {
|
||||
t.Errorf("ClientID = %q; want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user