Class: OmniAuth::Strategies::Feishu

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/feishu.rb

Defined Under Namespace

Classes: NoAppAccessTokenError

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#app_access_tokenObject (readonly)

Returns the value of attribute app_access_token.



8
9
10
# File 'lib/omniauth/strategies/feishu.rb', line 8

def app_access_token
  @app_access_token
end

Instance Method Details

#authorize_paramsObject



51
52
53
54
55
# File 'lib/omniauth/strategies/feishu.rb', line 51

def authorize_params
  super.tap do |params|
    params[:app_id] = options.client_id
  end
end

#build_access_tokenObject



57
58
59
60
61
62
63
64
65
# File 'lib/omniauth/strategies/feishu.rb', line 57

def build_access_token
  resp = Faraday.post(
    options.client_options.token_url,
    { code: request.params["code"], app_access_token: app_access_token, grant_type: "authorization_code" }.to_json,
    content_type: "application/json"
  )
  data = JSON.parse(resp.body)['data']
  ::OAuth2::AccessToken.from_hash(client, data)
end

#callback_phaseObject



67
68
69
70
# File 'lib/omniauth/strategies/feishu.rb', line 67

def callback_phase
  get_app_access_token
  super
end

#raw_infoObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/omniauth/strategies/feishu.rb', line 39

def raw_info
  @raw_info ||= begin
    response = Faraday.get(
      options.client_options.,
      nil,
      content_type: 'application/json', authorization: "Bearer #{access_token.token}"
    )
    response_body = JSON.parse(response.body)
    response_body['data']
  end
end