func (c *LoginController) Refresh(ctx *app.RefreshLoginContext) error {
	refreshToken := ctx.Payload.RefreshToken
	if refreshToken == nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("refresh_token", nil).Expected("not nil"))
	}

	client := &http.Client{Timeout: 10 * time.Second}
	endpoint, err := c.configuration.GetKeycloakEndpointToken(ctx.RequestData)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err,
		}, "Unable to get Keycloak token endpoint URL")
		return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError("unable to get Keycloak token endpoint URL "+err.Error()))
	}
	res, err := client.PostForm(endpoint, url.Values{
		"client_id":     {c.configuration.GetKeycloakClientID()},
		"client_secret": {c.configuration.GetKeycloakSecret()},
		"refresh_token": {*refreshToken},
		"grant_type":    {"refresh_token"},
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError("Error when obtaining token "+err.Error()))
	}
	switch res.StatusCode {
	case 200:
		// OK
	case 401:
		return jsonapi.JSONErrorResponse(ctx, errors.NewUnauthorizedError(res.Status+" "+rest.ReadBody(res.Body)))
	case 400:
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError(rest.ReadBody(res.Body), nil))
	default:
		return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError(res.Status+" "+rest.ReadBody(res.Body)))
	}

	token, err := auth.ReadToken(res)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	return ctx.OK(&app.AuthToken{Token: token})
}
// Refresh obtain a new access token using the refresh token.
Refresh obtain a new access token using the refresh token.
// Refresh obtain a new access token using the refresh token .
func (c *LoginController) Refresh(ctx *app.RefreshLoginContext) error {
	refreshToken := ctx.Payload.RefreshToken
	if refreshToken == nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("refresh_token", nil).Expected("not nil"))
	}
	client := &http.Client{Timeout: 10 * time.Second}
	endpoint, err := c.configuration.GetKeycloakEndpointToken(ctx.RequestData)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err,
		}, "Unable to get Keycloak token endpoint URL")
		return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError("unable to get Keycloak token endpoint URL "+err.Error()))
	}
	res, err := client.PostForm(endpoint, url.Values{
		"client_id":     {c.configuration.GetKeycloakClientID()},
		"client_secret": {c.configuration.GetKeycloakSecret()},
		"refresh_token": {*refreshToken},
		"grant_type":    {"refresh_token"},
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError("Error when obtaining token "+err.Error()))
	}
	switch res.StatusCode {
	case 200:
	case 401:
		return jsonapi.JSONErrorResponse(ctx, errors.NewUnauthorizedError(res.Status+" "+rest.ReadBody(res.Body)))
	case 400:
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError(rest.ReadBody(res.Body), nil))
	default:
		return jsonapi.JSONErrorResponse(ctx, errors.NewInternalError(res.Status+" "+rest.ReadBody(res.Body)))
	}
	token, err := auth.ReadToken(res)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	return ctx.OK(&app.AuthToken{Token: token})
}
func ( c * LoginController ) Refresh ( ctx * app . RefreshLoginContext ) error { refreshToken := ctx . Payload . RefreshToken if refreshToken == nil { return jsonapi . JSONErrorResponse ( ctx , errors . NewBadParameterError ( " " , nil ) . Expected ( " " ) ) } client := & http . Client { Timeout : 10 * time . Second } endpoint , err := c . configuration . GetKeycloakEndpointToken ( ctx . RequestData ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : err , } , " " ) return jsonapi . JSONErrorResponse ( ctx , errors . NewInternalError ( " " + err . Error ( ) ) ) } res , err := client . PostForm ( endpoint , url . Values { " " : { c . configuration . GetKeycloakClientID ( ) } , " " : { c . configuration . GetKeycloakSecret ( ) } , " " : { * refreshToken } , " " : { " " } , } ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , errors . NewInternalError ( " " + err . Error ( ) ) ) } switch res . StatusCode { case 200 : case 401 : return jsonapi . JSONErrorResponse ( ctx , errors . NewUnauthorizedError ( res . Status + " " + rest . ReadBody ( res . Body ) ) ) case 400 : return jsonapi . JSONErrorResponse ( ctx , errors . NewBadParameterError ( rest . ReadBody ( res . Body ) , nil ) ) default : return jsonapi . JSONErrorResponse ( ctx , errors . NewInternalError ( res . Status + " " + rest . ReadBody ( res . Body ) ) ) } token , err := auth . ReadToken ( res ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , err ) } return ctx . OK ( & app . AuthToken { Token : token } ) }
Refresh obtain a new access token using the refresh token.
Refresh obtain a new access token using the refresh token .
// OK