fix oauth token refresh.
make sure raw request query params are passed in.
This commit is contained in:
parent
38dbc465bf
commit
734dac28f6
|
@ -22,6 +22,7 @@ func NewClient(ctx context.Context, appConfig config.Interface, globalLogger log
|
|||
}, updatedSource, err
|
||||
}
|
||||
|
||||
//Overrides
|
||||
func (c AetnaClient) GetPatientBundle(patientId string) (fhir401.Bundle, error) {
|
||||
|
||||
bundle := fhir401.Bundle{}
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/oauth2"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
@ -42,7 +43,7 @@ func NewBaseClient(ctx context.Context, appConfig config.Interface, globalLogger
|
|||
ClientSecret: "",
|
||||
Endpoint: oauth2.Endpoint{
|
||||
AuthURL: source.OauthAuthorizationEndpoint,
|
||||
TokenURL: source.OauthTokenEndpointAuthMethods,
|
||||
TokenURL: source.OauthTokenEndpoint,
|
||||
},
|
||||
//RedirectURL: "",
|
||||
//Scopes: nil,
|
||||
|
@ -54,6 +55,7 @@ func NewBaseClient(ctx context.Context, appConfig config.Interface, globalLogger
|
|||
Expiry: time.Unix(source.ExpiresAt, 0),
|
||||
}
|
||||
if token.Expiry.Before(time.Now()) { // expired so let's update it
|
||||
log.Println("access token expired, refreshing...")
|
||||
src := conf.TokenSource(ctx, token)
|
||||
newToken, err := src.Token() // this actually goes and renews the tokens
|
||||
if err != nil {
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -181,7 +182,17 @@ func RawRequestSource(c *gin.Context) {
|
|||
}
|
||||
|
||||
var resp map[string]interface{}
|
||||
err = client.GetRequest(strings.TrimSuffix(c.Param("path"), "/"), &resp)
|
||||
|
||||
parsedUrl, err := url.Parse(strings.TrimSuffix(c.Param("path"), "/"))
|
||||
if err != nil {
|
||||
logger.Errorf("Error parsing request, %v", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})
|
||||
return
|
||||
}
|
||||
//make sure we include all query string parameters with the raw request.
|
||||
parsedUrl.RawQuery = c.Request.URL.Query().Encode()
|
||||
|
||||
err = client.GetRequest(parsedUrl.String(), &resp)
|
||||
if err != nil {
|
||||
logger.Errorf("Error making raw request, %v", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})
|
||||
|
|
Loading…
Reference in New Issue