Class: Frameio::Auth

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/frameio/auth.rb

Constant Summary collapse

AUTH_URL =
"https://applications.frame.io/oauth2/auth".freeze

Instance Method Summary collapse

Constructor Details

#initializeAuth

Returns a new instance of Auth.



8
9
# File 'lib/frameio/auth.rb', line 8

def initialize
end

Instance Method Details

#create_auth_token(auth_code:) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/frameio/auth.rb', line 23

def create_auth_token(auth_code:)
  body = {
    code: auth_code,
    grant_type: "authorization_code",
    redirect_uri: Frameio.configuration.auth_redirect_uri,
  }
  request(body)
end

#create_auth_url(state: "default_state") ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/frameio/auth.rb', line 11

def create_auth_url(state: "default_state")
  uri = Addressable::URI.new
  uri.query_values = {
    response_type: 'code',
    redirect_uri: Frameio.configuration.auth_redirect_uri,
    client_id: Frameio.configuration.client_id,
    scope: Frameio.configuration.scope,
    state: state
  }
  "#{AUTH_URL}?#{uri.query}"
end

#refresh_auth_token(token) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/frameio/auth.rb', line 32

def refresh_auth_token(token)
  refresh_token = find_refresh_token(token)
  body = {
    grant_type: "refresh_token",
    refresh_token: refresh_token
  }
  request(body)
end