Skip to content

Commit

Permalink
add verify credentias endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
andefined committed Sep 18, 2021
1 parent 2f202a3 commit 11067c3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions twitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
AccessTokenURL = "https://api.twitter.com/oauth/access_token"
TokenURL = "https://api.twitter.com/oauth2/token"
RateLimitStatusURL = "https://api.twitter.com/1.1/application/rate_limit_status.json"
VerifyCredentials = "https://api.twitter.com/1.1/account/verify_credentials.json"
)

// Twitter API Client
Expand Down Expand Up @@ -96,9 +97,9 @@ func (api *Twitter) GetClient() *http.Client {
}

// VerifyCredentials returns bool upon successful request. This method will make a request
// on the rate-limit endpoint since there is no official token validation method.
// on the account/verify_credentials endpoint.
func (api *Twitter) VerifyCredentials() (bool, *APIError) {
response, err := api.client.Get(RateLimitStatusURL)
response, err := api.client.Get(VerifyCredentials)
if err != nil {
return false, &APIError{0, err.Error()}
}
Expand Down

0 comments on commit 11067c3

Please sign in to comment.