MCPcopy
hub / github.com/daptin/daptin / oauthFormRequest

Function oauthFormRequest

server_test.go:1174–1199  ·  view source on GitHub ↗
(client *http.Client, endpoint string, clientID string, clientSecret string, form url.Values)

Source from the content-addressed store, hash-verified

1172}
1173
1174func oauthFormRequest(client *http.Client, endpoint string, clientID string, clientSecret string, form url.Values) (map[string]interface{}, error) {
1175 httpReq, err := http.NewRequest("POST", endpoint, strings.NewReader(form.Encode()))
1176 if err != nil {
1177 return nil, err
1178 }
1179 httpReq.SetBasicAuth(clientID, clientSecret)
1180 httpReq.Header.Set("Content-Type", "application/x-www-form-urlencoded")
1181
1182 resp, err := client.Do(httpReq)
1183 if err != nil {
1184 return nil, err
1185 }
1186 defer resp.Body.Close()
1187
1188 var body map[string]interface{}
1189 if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
1190 if resp.StatusCode >= 200 && resp.StatusCode < 300 {
1191 return map[string]interface{}{}, nil
1192 }
1193 return nil, err
1194 }
1195 if resp.StatusCode >= 400 {
1196 return body, fmt.Errorf("oauth form request failed: %d %v", resp.StatusCode, body)
1197 }
1198 return body, nil
1199}
1200
1201func oauthAppAction(client *http.Client, baseAddress string, daptinToken string, actionName string, oauthAppRef string, attributes map[string]interface{}) (map[string]interface{}, error) {
1202 if attributes == nil {

Callers 2

runOAuthProviderE2ETestsFunction · 0.85
oauthTokenRequestFunction · 0.85

Calls 3

EncodeMethod · 0.80
SetMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected