123456789_123456789_123456789_123456789_123456789_

Module: Octokit::Client::Tokens

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/octokit/client/tokens.rb

Overview

Instance Method Summary

Instance Method Details

#scopes(token = @access_token, options = {}) ⇒ Array<String>

Check scopes for a token

Parameters:

  • token (String) (defaults to: @access_token)

    GitHub OAuth token

  • options (Hash) (defaults to: {})

    Header params for request

Returns:

  • (Array<String>)

    OAuth scopes

Raises:

  • (ArgumentError)

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/tokens.rb', line 15

def scopes(token = @access_token, options = {})
  options = options.dup
  raise ArgumentError, 'Access token required' if token.nil?

  auth = { 'Authorization' => "token #{token}" }
  headers = (options.delete(:headers) || {}).merge(auth)

  agent.call(:get, 'user', headers: headers)
       .headers['X-OAuth-Scopes']
       .to_s
       .split(',')
       .map(&:strip)
       .sort
end