dry-book-88542
03/29/2022, 1:20 PMmagnificent-energy-493
bulky-holiday-60244
03/29/2022, 3:31 PMdamp-sunset-69236
03/29/2022, 3:50 PMconfig := client.NewConfiguration()
config.Servers = []client.ServerConfiguration{
{
URL: "<https://hydra.localhost:4445>", // Admin API
},
}
c := client.NewAPIClient(config)
consentReq := c.AdminApi.GetConsentRequest(context.Todo())
// change params
consentRequest, res, err := consentReq.Execute()
if err != nil { //Handle error}
switch res.StatusCode {
case http.StatusNotFound:
// Handle
// Equals to *hydra_admin.GetConsentRequestNotFound
case http.StatusGone:
// Handle it
default:
}
bulky-holiday-60244
03/29/2022, 4:00 PMmagnificent-energy-493
bulky-holiday-60244
03/29/2022, 4:07 PMhydra_admin.RequestWasHandledResponse
damp-sunset-69236
03/29/2022, 4:11 PMpackage main
import (
"context"
"fmt"
"net/http"
"os"
client "<http://github.com/ory/hydra-client-go|github.com/ory/hydra-client-go>"
)
func main() {
consentChallenge := "consentChallenge_example" // string |
configuration := client.NewConfiguration()
configuration.Servers = []client.ServerConfiguration{
{
URL: "<http://localhost:4445>", // Admin API
},
}
apiClient := client.NewAPIClient(configuration)
resp, r, err := apiClient.AdminApi.GetConsentRequest(context.Background()).ConsentChallenge(consentChallenge).Execute()
if err != nil {
switch r.StatusCode {
case http.StatusNotFound:
fmt.Println("Consent not found")
case http.StatusGone:
fmt.Println("It's gone")
default:
fmt.Fprintf(os.Stderr, "Error when calling `AdminApi.GetConsentRequest``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
}
// response from `GetConsentRequest`: ConsentRequest
fmt.Fprintf(os.Stdout, "Response from `AdminApi.GetConsentRequest`: %v\n", resp)
}
magnificent-energy-493
damp-sunset-69236
03/29/2022, 4:16 PMbulky-holiday-60244
03/29/2022, 4:24 PMerrPayload, ok := httpResp.(*hydra_client.RequestWasHandledResponse)
damp-sunset-69236
03/29/2022, 4:35 PMbulky-holiday-60244
03/29/2022, 4:35 PMRequestWasHandledResponse
, but which one ^^?damp-sunset-69236
03/29/2022, 4:36 PMbulky-holiday-60244
03/29/2022, 4:36 PMRequestWasHandledResponse
.RequestWasHandledResponse
that embeds "RedirectTo", but I don't know from where I should get it since I'm not able to cast any of the three variable returneddamp-sunset-69236
03/29/2022, 4:39 PMbulky-holiday-60244
03/29/2022, 4:44 PMModel()
does not exist. Maybe I have to first cast "error" interface into something?damp-sunset-69236
03/29/2022, 4:45 PMerr.(*client.GenericOpenAPIError).Model().(client.RequestWasHandledResponse)
Jesusbulky-holiday-60244
03/29/2022, 4:47 PMa, ok := err.(*hydra_client.GenericOpenAPIError)
b, ok := a.Model().(*hydra_client.RequestWasHandledResponse)
damp-sunset-69236
03/29/2022, 4:50 PMswitch r.StatusCode {
case http.StatusNotFound:
notFound, ok := err.(*client.GenericOpenAPIError).Model().(client.JsonError)
fmt.Println(ok)
fmt.Println(*notFound.ErrorDescription)
....
bulky-holiday-60244
03/29/2022, 4:52 PMdamp-sunset-69236
03/29/2022, 4:53 PMbulky-holiday-60244
03/29/2022, 4:54 PMdamp-sunset-69236
03/29/2022, 4:56 PMbulky-holiday-60244
03/29/2022, 4:57 PMdamp-sunset-69236
03/29/2022, 5:18 PMpackage main
import (
"context"
"fmt"
"os"
openapiclient "./openapi"
)
func main() {
consentChallenge := "consentChallenge_example" // string |
rejectRequest := *openapiclient.NewRejectRequest() // RejectRequest | (optional)
configuration := openapiclient.NewConfiguration()
apiClient := openapiclient.NewAPIClient(configuration)
resp, r, err := apiClient.AdminApi.RejectConsentRequest(context.Background()).ConsentChallenge(consentChallenge).RejectRequest(rejectRequest).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `AdminApi.RejectConsentRequest``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
// response from `RejectConsentRequest`: CompletedRequest
fmt.Fprintf(os.Stdout, "Response from `AdminApi.RejectConsentRequest`: %v\n", resp)
}
bulky-holiday-60244
03/29/2022, 5:23 PMAcceptConsentRequest(ctx).ConsentChallenge(challenge).AcceptConsentRequest(hydra_client.AcceptConsentRequest{
(contrary to RejectConsentRequest(context.Background()).ConsentChallenge(consentChallenge).RejectRequest(rejectRequest
)
Probably too tired to think about it, will stop wasting your time 🙂
Thanks again!damp-sunset-69236
03/29/2022, 5:24 PMbulky-holiday-60244
03/29/2022, 5:38 PMmap[string]map[string]interface{}
I tried to look at hydra_client.NewAcceptConsentRequest()
to see if there was an example but no.
EDIT: please see last post on the channel, will make things clearer (sorry Andreas for spamming your thread :s )