1

I am still a bit new with Ruby On Rails I managed to connect a youtube API without issues for pulling live streams. Now I am trying to do the same with Twitch and I found this gem https://github.com/mauricew/ruby-twitch-api . I am just confused as to where this part goes

twitch_client = Twitch::Client.new(
  client_id: client_id,
  client_secret: client_secret,

  ## this is default
  # token_type: :application,

  ## this can be required by some Twitch end-points
  # scopes: scopes,

  ## if you already have one
  # access_token: access_token
)

I already registered it with Twitch and have my client id and client secret. I would like to first run it via bin/rails c just to test everything. Anyone have any ideas?

2 Answers2

1

Add your code snippet directly in the console, and the you can use twitch_client to use the API.

Note that you'll need access to this twitch_client to use it, or to create another instance

Jaffa
  • 12,442
  • 4
  • 49
  • 101
0

And on whether where you should put this code snippet. You can put it in a initializer in rails. So you will have the following:

config/initializers/twitch_client.rb

Link that is similar to yours: Rails initializer

Dharman
  • 30,962
  • 25
  • 85
  • 135
AceCleric
  • 36
  • 2