Class: OmniAuth::Strategies::Feishu
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Feishu
- Defined in:
- lib/omniauth/strategies/feishu.rb
Overview
飞书登录
飞书要求请求采用 json 格式主体,很多都需要自定义 官方文档: open.feishu.cn/document/ukTMukTMukTM/uETOwYjLxkDM24SM5AjN
Defined Under Namespace
Classes: NoAppAccessTokenError
Instance Method Summary collapse
- #authorize_params ⇒ Object
-
#build_access_token ⇒ Object
飞书采用非标准 OAuth 2 请求体和返回结构体,需要自定义.
- #raw_info ⇒ Object
Instance Method Details
#authorize_params ⇒ Object
51 52 53 54 55 |
# File 'lib/omniauth/strategies/feishu.rb', line 51 def super.tap do |params| params[:app_id] = .client_id end end |
#build_access_token ⇒ Object
飞书采用非标准 OAuth 2 请求体和返回结构体,需要自定义
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/omniauth/strategies/feishu.rb', line 58 def build_access_token code = request.params['code'] data = client.request(:post, ..token_url, { body: { code: code, grant_type: 'authorization_code' }.to_json, headers: { 'Content-Type' => 'application/json; charset=utf-8', 'Authorization' => "Bearer #{app_access_token}" } }) .parsed['data'] ::OAuth2::AccessToken.from_hash(client, data) end |
#raw_info ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/omniauth/strategies/feishu.rb', line 41 def raw_info @raw_info ||= client.request(:get, ..user_info_url, { headers: { 'Content-Type' => 'application/json; charset=utf-8', 'Authorization' => "Bearer #{access_token.token}" } }) .parsed['data'] end |