<@U07NG3B42HK> here is an example: package main...
# general
s
@numerous-vr-11590 here is an example: package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "strings" ) func main() { // Replace these variables with your actual values tokenEndpoint := "https://auth-server.com/oauth2/token" clientID := "your-client-id" clientSecret := "your-client-secret" redirectURI := "https://your-app.com/callback" authorizationCode := "authorization-code-from-auth" // Create the form data (URL-encoded) for the token request data := url.Values{} data.Set("grant_type", "authorization_code") data.Set("code", authorizationCode) data.Set("redirect_uri", redirectURI) data.Set("client_id", clientID) data.Set("client_secret", clientSecret) // Create the POST request req, err := http.NewRequest("POST", tokenEndpoint, strings.NewReader(data.Encode())) if err != nil { fmt.Println("Error creating request:", err) return } // Set the appropriate headers for form submission req.Header.Set("Content-Type", "application/x-www-form-urlencoded") // Perform the request client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer resp.Body.Close() // Read the response body body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response:", err) return } // Parse and print the response (assuming JSON response) if resp.StatusCode == http.StatusOK { var responseMap map[string]interface{} if err := json.Unmarshal(body, &responseMap); err != nil { fmt.Println("Error parsing JSON response:", err) return } fmt.Printf("Token Response: %+v\n", responseMap) } else { fmt.Printf("Failed to get token, status: %d, response: %s\n", resp.StatusCode, string(body)) } }
n
Hi @swift-chef-97535, I mean Post method with Authorization endpoint, not token endpoint. I've mentioned more details here- https://ory-community.slack.com/archives/C02MR4DEEGH/p1727093748322519 Can you please look into this ?
Below is curl which I am using. ---------------------------- curl --location 'https://localhost:4444/oauth2/auth' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'client_id={{client_id}}' \ --data-urlencode 'redirect_uri=https://oauth.pstmn.io/v1/callback' \ --data-urlencode 'response_type=code' \ --data-urlencode 'state=123456789' \ --data-urlencode 'audience={{audience}}' \ --data-urlencode 'scope=fhirUser openid launch offline_access' ------------------------------ I want to avoid passing parameters in url itslef; I want to pass parameters value as request body instead. Does hydra support to accept POST requests for the '*oauth2/auth'* endpoint ?