Skip to content

Commit

Permalink
proper returns
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio committed May 25, 2023
1 parent 629a267 commit a0ef650
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions auth/OpenAiAuth.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,14 @@ func (auth *Authenticator) GetAccessToken() (string, Error) {
defer resp.Body.Close()
// Parse response
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
// Parse as JSON
var data map[string]interface{}

return "", Error{}
err = json.Unmarshal(body, &data)

if err != nil {
return "", *NewError("get_access_token", 0, "", err)
}

return data["access_token"].(string), Error{}
}

0 comments on commit a0ef650

Please sign in to comment.