Create a user on website with twitch oauth (ruby)


#1

Hi. I’m extremely new to web dev, so apologies if this has been discussed before. I’ve read nearly everything Barry Carlyon has posted on this site and still can’t figure out a solution.

Basically, I’m trying to create a user for my webpage after they’ve authorized with oauth. I already have the oauth part figured out, and I’m successfully accessing an access token and saving it to variable access_token. I then initialize a client.

client = Twitch::Client.new(:access_token => access_token)

When I code

puts client

#Twitch::User:0x00007fa84f29#### is returned. So my questions are:

  1. How can I use this object to access various user info, such as email, display_name, and profile_image_url? (I included get:user:email as the scope in the initial GET.)

  2. How can I store an instance of this user in my DB?

This is what I’ve tried so far:

user = client.get_users.data

profile_data = { :profile_image_url => user.profile_image_url, :display_name => user.display_name, :email => user.email, :id => user.id }

Thanks a ton in advance.


#2

Use the access token with a GET to this endpoint

Omitting the id/login optional query string parameters

  1. After collecting the data, you just need to use whatever Ruby uses for DB stuff and/or whatever Twitch::client is

But this looks like like a question about what Twitch::client is for Ruby, supports and does rather than a general API question!


#3

Apologies for that, can you move the topic?


#4

Not really, we don’t have a Twitch::client for ruby support forum on this forum. Someone might chime in but Twitch::client probably has it’s own place to get support for it.

But you should be able to grab the access token from the client and make your own call to the Twitch API via whatever Ruby supports for making HTTP/API requests


#5

Well thanks for the help regardless! I think I can manage from here