Module: Google::Auth::ScopeUtil

Defined in:
lib/googleauth/scope_util.rb

Overview

Small utility for normalizing scopes into canonical form

Constant Summary collapse

ALIASES =
{
  'email' => 'https://www.googleapis.com/auth/userinfo.email',
  'profile' => 'https://www.googleapis.com/auth/userinfo.profile',
  'openid' => 'https://www.googleapis.com/auth/plus.me'
}.freeze

Class Method Summary collapse

Class Method Details

.as_array(scope) ⇒ Object



49
50
51
52
53
54
55
56
57
58
# File 'lib/googleauth/scope_util.rb', line 49

def self.as_array(scope)
  case scope
  when Array
    scope
  when String
    scope.split(' ')
  else
    raise 'Invalid scope value. Must be string or array'
  end
end

.normalize(scope) ⇒ Object



44
45
46
47
# File 'lib/googleauth/scope_util.rb', line 44

def self.normalize(scope)
  list = as_array(scope)
  list.map { |item| ALIASES[item] || item }
end