Class: OmniAuth::Strategies::Roblox
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Roblox
- Defined in:
- lib/omniauth-roblox/omniauth/strategies/roblox.rb
Overview
This is the Roblox OAuth/OIDC strategy Currently their API is in private beta If you are enrolled, you may register at create.roblox.com/credentials
Instance Method Summary collapse
-
#authorize_params ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#image_url ⇒ Object
rubocop:disable Metrics.
- #raw_info ⇒ Object
-
#verified_email ⇒ Object
Roblox currently does not allow third parties to access user emails, this is only added for completeness.
Instance Method Details
#authorize_params ⇒ Object
rubocop:disable Metrics/AbcSize
27 28 29 30 31 32 33 34 35 |
# File 'lib/omniauth-roblox/omniauth/strategies/roblox.rb', line 27 def # rubocop:disable Metrics/AbcSize super.tap do |params| [:authorize_options].each do |k| params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s]) end session['omniauth.state'] = params[:state] if params[:state] end end |
#image_url ⇒ Object
rubocop:disable Metrics
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/omniauth-roblox/omniauth/strategies/roblox.rb', line 78 def image_url # rubocop:disable Metrics return nil if [:skip_image] url = 'https://thumbnails.roblox.com/v1/users/avatar' url_additions = { bust: '-bust', headshot: '-headshot' } uri = URI(url + url_additions[[:image_type]]) uri.query = URI.encode_www_form({ userIds: raw_info['sub'], size: '720x720', format: 'Png', isCircular: 'false' }) res = Net::HTTP.get_response(uri) data = JSON.parse(res.body).data.first res.is_a?(Net::HTTPSuccess) ? data.imageUrl : nil end |
#raw_info ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/omniauth-roblox/omniauth/strategies/roblox.rb', line 53 def raw_info @raw_info ||= JSON.parse( Base64.urlsafe_decode( access_token['id_token'].split('.')[1] ) ) return if @raw_info['name'] user_api_res = Net::HTTP.get_response(URI("https://users.roblox.com/v1/users/#{uid}")) # The Roblox Users API returns usernames under the `name` property # Unlike the id_token where it is the display name return unless user_api_res.is_a?(Net::HTTPSuccess) api_data = JSON.parse(user_api_res.body) @raw_info['nickname'] = api_data['name'] @raw_info['name'] = api_data['displayName'] end |
#verified_email ⇒ Object
Roblox currently does not allow third parties to access user emails, this is only added for completeness
74 75 76 |
# File 'lib/omniauth-roblox/omniauth/strategies/roblox.rb', line 74 def verified_email raw_info['email_verified'] ? raw_info['email'] : nil end |