Sha256: 35151ee3443f4dc938fc47e204136bedb3e11ba94ca876c7cce73cae97975fa1

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'omniauth-oauth2'


module OmniAuth
  module Strategies
    class Threads < OmniAuth::Strategies::OAuth2
      option :name, "threads"

      option :client_options, {
        site: "https://graph.threads.net/",
        authorize_url: "https://threads.net/oauth/authorize",
        token_url: 'oauth/access_token'
      }

      def token_params
        super.tap do |params|
          params.client_secret = options.client_secret
          params.client_id = options.client_id
        end
      end

      def callback_url
        super.split("?").first
      end



      uid { raw_info['id'] }

      info do
        {
          :nickname => raw_info['username'],
          :name => raw_info['username'],
          :email => raw_info["email"],
          :image => raw_info['threads_profile_picture_url'],
          :description => raw_info['threads_biography'],
        }
      end

      extra do
        {
          'raw_info' => raw_info
        }
      end

      def raw_info
        @raw_info ||= access_token.get('/me?fields=id,username,threads_profile_picture_url,threads_biography').parsed
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-threads-0.1.2 lib/omniauth/strategies/threads.rb