WebTheoryLLC / omniauth-twitch

OmniAuth Strategy for Twitch
MIT License
32 stars 22 forks source link

Fix for Twitch API requiring Client-ID header #18

Closed deanpcmad closed 4 years ago

deanpcmad commented 4 years ago

Fixes #17

Eein commented 4 years ago

So just by changing the raw_info fix you made locally, i'm receiving the following error: {"error":"Unauthorized","status":401,"message":"OAuth token is missing"}

Its very likely something wrong with the version of omniauth-oauth2 i'm using but i'll gladly try this pr in its entirety to see if its a dependency issue.

deanpcmad commented 4 years ago

Yeah, possibly. I thought it would be best to update the omniauth-oauth2 gem anyway as this gem hasn't been updated in a while! I've just deployed this gem on my production app and login now works so I'm happy!

Eein commented 4 years ago

Yep!

Looks like a dependency conflict with another package using an older version of omniauth-oauth2 that unfortunately I cannot resolve at this time.

My current conflict holds me back to omniauth-oauth2 1.3.1, so if anyone is locked to an older version they may have breaking changes here to contend with in other packages. In the newest version of my conflicting package, it has an upgrade to 1.4.

If anyone else is unable to upgrade due to a conflict (mine is very spooky to update), what i did to resolve the issue was generate my own faraday request:

      def get_raw_info
        url = "https://api.twitch.tv/helix/users"
        con = Faraday.new
        res = con.get do |req|
          req.url url
          req.headers['Client-ID'] = "#{access_token.client.id}"
          req.headers['Authorization'] = "Bearer #{access_token.token}"
        end
        body = JSON.parse(res.body)
        body["data"][0]
      end

With that said, I'd recommend also adding a minor version bump to this PR as it will definitely break some peoples implementations. (if the maintainer has no objections)

brettmhammond commented 4 years ago

This really needs to get merged and deployed out ASAP. Today was the final cutoff.

jcgertig commented 4 years ago

This has been released

deanpcmad commented 4 years ago

Great, thanks!