Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to Go modules and add error handling for HTTP requests #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module github.com/IntuitDeveloper/OAuth2-Go.git

go 1.18

require (
github.com/IntuitDeveloper/OAuth2-Go v0.0.0-20180522130730-95e7b650e6d6
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/twinj/uuid v1.0.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/myesui/uuid v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/stretchr/testify.v1 v1.2.2 // indirect
)
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
github.com/IntuitDeveloper/OAuth2-Go v0.0.0-20180522130730-95e7b650e6d6 h1:/V/98ZhG0fLT2cSq8b6qECMSaJkypuD3SdNSRRSoDHo=
github.com/IntuitDeveloper/OAuth2-Go v0.0.0-20180522130730-95e7b650e6d6/go.mod h1:Aoq7T2ZQfQ+HirG/3N6e8sQvdB0w4WK2xBqyG7gQRl4=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/myesui/uuid v1.0.0 h1:xCBmH4l5KuvLYc5L7AS7SZg9/jKdIFubM7OVoLqaQUI=
github.com/myesui/uuid v1.0.0/go.mod h1:2CDfNgU0LR8mIdO8vdWd8i9gWWxLlcoIGGpSNgafq84=
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/twinj/uuid v1.0.0 h1:fzz7COZnDrXGTAOHGuUGYd6sG+JMq+AoE7+Jlu0przk=
github.com/twinj/uuid v1.0.0/go.mod h1:mMgcE1RHFUFqe5AfiwlINXisXfDGro23fWdPUfOMjRY=
gopkg.in/stretchr/testify.v1 v1.2.2 h1:yhQC6Uy5CqibAIlk1wlusa/MJ3iAN49/BsR/dCCKz3M=
gopkg.in/stretchr/testify.v1 v1.2.2/go.mod h1:QI5V/q6UbPmuhtm10CaFZxED9NreB8PnFYN9JcR6TxU=
3 changes: 3 additions & 0 deletions handlers/bearerToken.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func RetrieveBearerToken(code string) (*BearerTokenResponse, error) {
request.Header.Set("Authorization", "Basic "+basicAuth())

resp, err := client.Do(request)
if err != nil {
log.Fatalln(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions handlers/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func CallDiscoveryAPI() {
request.Header.Set("accept", "application/json")

resp, err := client.Do(request)
if err != nil {
log.Fatalln(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions handlers/jwks.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func CallJWKSAPI() (*JWKSResponse, error) {
request.Header.Set("accept", "application/json")

resp, err := client.Do(request)
if err != nil {
log.Fatalln(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions handlers/qboCompanyInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ func GetCompanyInfo(w http.ResponseWriter, r *http.Request) {
request.Header.Set("Authorization", "Bearer "+accessToken)

resp, err := client.Do(request)
if err != nil {
log.Fatalln(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions handlers/refreshToken.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ func RefreshToken(w http.ResponseWriter, r *http.Request) {
request.Header.Set("Authorization", "Basic "+basicAuth())

resp, err := client.Do(request)
if err != nil {
log.Fatalln(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions handlers/revokeToken.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func RevokeToken(w http.ResponseWriter, r *http.Request) {
request.Header.Set("Authorization", "Basic "+basicAuth())

resp, err := client.Do(request)
if err != nil {
log.Fatalln(err)
}
defer resp.Body.Close()

responseString := map[string]string{"response": "Revoke successful"}
Expand Down
3 changes: 3 additions & 0 deletions handlers/userInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func GetUserInfo(w http.ResponseWriter, r *http.Request, accessToken string) (*U
request.Header.Set("Authorization", "Bearer "+accessToken)

resp, err := client.Do(request)
if err != nil {
log.Fatalln(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
Expand Down