Skip to content

Commit

Permalink
Don't try to refresh applicaton tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWayfer committed Nov 17, 2020
1 parent e844ec0 commit 5d5849c
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 94 deletions.
6 changes: 4 additions & 2 deletions lib/twitch/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ def initialize(options = {})
client_id: client_id, **options.slice(:client_secret, :redirect_uri, :scopes)
)

@token_type = options.fetch(:token_type, :application)

@tokens = @oauth2_client.check_tokens(
**options.slice(:access_token, :refresh_token),
token_type: options.fetch(:token_type, :application)
**options.slice(:access_token, :refresh_token), token_type: @token_type
)

CONNECTION.headers['Client-ID'] = client_id
Expand Down Expand Up @@ -142,6 +143,7 @@ def request(http_method, *args)
def require_access_token
response = yield
if response.success? ||
@token_type != :user ||
response.status != 401 ||
## Here can be another error, like "missing required oauth scope"
response.body[:message] != 'invalid oauth token'
Expand Down

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

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

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

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

Loading

0 comments on commit 5d5849c

Please sign in to comment.