summaryrefslogtreecommitdiff
path: root/gettoken.rb
diff options
context:
space:
mode:
Diffstat (limited to 'gettoken.rb')
-rwxr-xr-xgettoken.rb45
1 files changed, 45 insertions, 0 deletions
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