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



34
35
36
37
38
39
40
41
42
43
# File 'lib/googleauth/scope_util.rb', line 34

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



29
30
31
32
# File 'lib/googleauth/scope_util.rb', line 29

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