Skip to content

Commit

Permalink
Worked on Ensuring that Log.Fatal is removed completetly as it closes…
Browse files Browse the repository at this point in the history
… the applicaiton unexpectedly
  • Loading branch information
Amenacliff committed May 23, 2022
1 parent 1b4aae2 commit 7724323
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/twitter-oauth.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions desktop_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func (d *DesktopClient) DoAuth() error {
requestToken, u, err := d.OAuthConsumer.GetRequestTokenAndUrl("oob")
fmt.Println("rest token=", requestToken, " err=", err)
if err != nil {
log.Fatal(err)
log.Println(err)
return err
}

fmt.Println("(1) Go to: " + u)
Expand All @@ -45,12 +46,14 @@ func (d *DesktopClient) DoAuth() error {

accessToken, err := d.OAuthConsumer.AuthorizeToken(requestToken, verificationCode)
if err != nil {
log.Fatal(err)
log.Println(err)
return err
}

d.HttpConn, err = d.OAuthConsumer.MakeHttpClient(accessToken)
if err != nil {
log.Fatal(err)
log.Println(err)
return err
}

return err
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module twitter

go 1.18

require github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450 h1:j2kD3MT1z4PXCiUllUJF9mWUESr9TWKS7iEKsQ/IipM=
github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450/go.mod h1:skjdDftzkFALcuGzYSklqYd8gvat6F1gZJ4YPVbkZpM=
13 changes: 8 additions & 5 deletions server_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,29 @@ type ServerClient struct {
OAuthTokens map[string]*oauth.RequestToken
}

func (s *ServerClient) GetAuthURL(tokenUrl string) string {
func (s *ServerClient) GetAuthURL(tokenUrl string) (string, error) {
token, requestUrl, err := s.OAuthConsumer.GetRequestTokenAndUrl(tokenUrl)

if err != nil {
log.Fatal(err)
log.Println(err)
return "", nil
}
// Make sure to save the token, we'll need it for AuthorizeToken()
s.OAuthTokens[token.Token] = token
return requestUrl
return requestUrl, nil
}

func (s *ServerClient) CompleteAuth(tokenKey, verificationCode string) error {
accessToken, err := s.OAuthConsumer.AuthorizeToken(s.OAuthTokens[tokenKey], verificationCode)
if err != nil {
log.Fatal(err)
log.Println(err)
return err
}

s.HttpConn, err = s.OAuthConsumer.MakeHttpClient(accessToken)
if err != nil {
log.Fatal(err)
log.Println(err)
return err
}
return nil
}

0 comments on commit 7724323

Please sign in to comment.