From d7eef063a7d993dcd91a701f151597a678b09190 Mon Sep 17 00:00:00 2001 From: Joe Rayhawk Date: Wed, 21 Oct 2015 16:47:05 -0700 Subject: twitchtools: initial commit --- gettoken.rb | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 gettoken.rb (limited to 'gettoken.rb') diff --git a/gettoken.rb b/gettoken.rb new file mode 100755 index 0000000..7896e5a --- /dev/null +++ b/gettoken.rb @@ -0,0 +1,45 @@ +#!/usr/bin/ruby + +require 'twitch' +require 'pp' + +confdir = Dir.home + '/.config/twitch/' +ENV['APPDATA'] && confdir = ENV['APPDATA'] + "\\twitch\\" +ENV['XDG_CONFIG_HOME'] && confdir = ENV['XDG_CONFIG_HOME'] + '/twitch/' + +client_id = IO.read( confdir+'client_id' ).chomp +secret_key = IO.read( confdir+'secret_key' ).chomp +redirect_uri = IO.read( confdir+'redirect_uri' ).chomp + +# Feel free to use https://www.omgwallhack.org/toys/env.cgi as a redirect URI; I am probably too lazy to steal your oauth token. + +scope = ' +user_read +user_blocks_edit +user_blocks_read +user_follows_edit +channel_read +channel_editor +channel_commercial +channel_stream +channel_subscriptions +channel_check_subscription +chat_login +'.split.sort.uniq + +twitch = Twitch.new({ + :client_id => client_id, + :secret_key => secret_key, + :redirect_uri => redirect_uri, + :scope => scope, +}) + +print( twitch.getLink + "\n" ) + +#access_token = twitch.auth(code)[:body]["access_token"] +# +#twitch=Twitch.new({ +# :access_token => access_token +#}) +# +#channel = twitch.getYourChannel -- cgit v1.2.3