mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-20 03:27:02 -07:00
Added refresh token flow
This commit is contained in:
parent
6938037a3c
commit
16ec8fc422
4 changed files with 56 additions and 2 deletions
|
|
@ -211,6 +211,10 @@ func (client *Client) PerformTokenGrant(clientUrl string, encodedJwt string) ([]
|
|||
}
|
||||
|
||||
_, b, err := httpx.MakeHttpRequest(clientUrl, http.MethodPost, []byte(body), headers)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to make HTTP request: %v", err)
|
||||
|
||||
}
|
||||
|
||||
// set flow ID back to empty string to indicate a completed flow
|
||||
client.FlowId = ""
|
||||
|
|
@ -218,6 +222,18 @@ func (client *Client) PerformTokenGrant(clientUrl string, encodedJwt string) ([]
|
|||
return b, err
|
||||
}
|
||||
|
||||
func (client *Client) PerformRefreshTokenGrant(url string, refreshToken string) ([]byte, error) {
|
||||
body := httpx.Body("grant_type=refresh_token" +
|
||||
"&refresh_token=" + refreshToken +
|
||||
"&scope" + strings.Join(client.Scope, "+"))
|
||||
headers := httpx.Headers{}
|
||||
_, b, err := httpx.MakeHttpRequest(url, http.MethodPost, body, headers)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to make HTTP request: %v", err)
|
||||
}
|
||||
return b, err
|
||||
}
|
||||
|
||||
func (client *Client) DeleteOAuthClient(clientUrl string) error {
|
||||
_, _, err := httpx.MakeHttpRequest(clientUrl+"/"+client.Id, http.MethodDelete, nil, nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue