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

OAuth Token is missing response when trying to use any function #4

Closed
ankoure opened this issue Jan 2, 2021 · 3 comments
Closed

OAuth Token is missing response when trying to use any function #4

ankoure opened this issue Jan 2, 2021 · 3 comments

Comments

@ankoure
Copy link

ankoure commented Jan 2, 2021

When I try to work through the example I receive this response. Unclear where the Oauth token is supposed to be added.

Error in get_streams(first = 15, language = "en") :
OAuth token is missing

@Freguglia
Copy link
Owner

Hi @ankoure, thanks for letting me know. Did you setup your credentials using the twitch_auth() function as specified in the Authenticantion section of the README file?

You can setup an OAuth token by calling the twitch_auth() function after you setup TWITCH_CLIENT_ID and TWITCH_CLIENT_SECRET as environment variables.

@ankoure
Copy link
Author

ankoure commented Jan 3, 2021

I added the TWITCH_CLIENT_ID and TWITCH_CLIENT_SECRET to the r environ file, then restarted R. I used the twitch_auth() function and it ran without an error but it did not prompt anything additional. Is twitch_auth() supposed to prompt something or should I be using the auth token in the function?

@Freguglia
Copy link
Owner

twitch_auth() handles the authentication process automatically, so you never really have to deal with the tokens manually. What it does in the backend is:

  • a POST request to https://id.twitch.tv/oauth2/token is sent using the credentials (TWITCH_CLIENT_ID and TWITCH_CLIENT_SECRET) found in your .Renviron file.
  • an access token is then created by the Twitch API and it is sent to you in the response of the request, as described in the Client credentials flow
  • the received access token is read and passed to httr's set_config() so that it will be automatically passed as a header in future requests made by httr.
  • now any request made by the package's functions (e.g. get_streams()) is made with the token as a header.

In summary, twitch_auth() obtains the token for you and automatically adds it to every future request made by rTwitchAPI functions. If it ran without any error, then the other functions should work normally.

I think I'll add some kind of feedback in twitch_auth() so that is becomes clearer that something happened in the background and you're now able to use the other functions.

@ankoure ankoure closed this as completed Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants