forked from Mirrors/oauth2
temp
This commit is contained in:
parent
8ea360249f
commit
58b935b4ea
|
@ -22,20 +22,6 @@ func ExchangeToken(endpoint string, request *STSTokenExchangeRequest, authentica
|
||||||
data.Set("subject_token", request.SubjectToken)
|
data.Set("subject_token", request.SubjectToken)
|
||||||
data.Set("scope", strings.Join(request.Scope, " "))
|
data.Set("scope", strings.Join(request.Scope, " "))
|
||||||
|
|
||||||
//req, err := http.NewRequest("POST", endpoint, strings.NewReader(data.Encode()))
|
|
||||||
//if err != nil {
|
|
||||||
// fmt.Errorf("oauth2/google: failed to properly build http request")
|
|
||||||
//}
|
|
||||||
//for key, _ := range headers {
|
|
||||||
// for _, val := range headers.Values(key) {
|
|
||||||
// req.Header.Add(key, val)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//if authentication.ClientID != "" && authentication.ClientSecret != "" {
|
|
||||||
// plainHeader := authentication.ClientID + ":" + authentication.ClientSecret
|
|
||||||
// req.Header.Add("Authorization", "Basic "+base64.StdEncoding.EncodeToString([]byte(plainHeader)))
|
|
||||||
//}
|
|
||||||
//req.Header.Add("Content-Length", strconv.Itoa(len(data.Encode())))
|
|
||||||
authentication.InjectAuthentication(&data, &headers)
|
authentication.InjectAuthentication(&data, &headers)
|
||||||
req, err := http.NewRequest("POST", endpoint, strings.NewReader(data.Encode()))
|
req, err := http.NewRequest("POST", endpoint, strings.NewReader(data.Encode()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
package externalaccount
|
package externalaccount
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
stsExchange_test.go
|
|
||||||
|
|
||||||
package externalaccount
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
|
@ -97,6 +87,7 @@ func TestExchangeToken(t *testing.T) {
|
||||||
if diff := cmp.Diff(*r, serverReq); diff != "" {
|
if diff := cmp.Diff(*r, serverReq); diff != "" {
|
||||||
t.Errorf("mismatched messages received by mock server (-want +got): \n%s", diff)
|
t.Errorf("mismatched messages received by mock server (-want +got): \n%s", diff)
|
||||||
}
|
}
|
||||||
|
if r.URL.String() !=
|
||||||
|
|
||||||
return
|
return
|
||||||
}))
|
}))
|
||||||
|
|
Loading…
Reference in New Issue