Module: Model::App::ReadApp

Extended by:
ActiveSupport::Concern
Included in:
Wechat::ReadApp
Defined in:
app/models/wechat/model/app/read_app.rb

Instance Method Summary collapse

Instance Method Details

#oauth2_url(scope = 'snsapi_userinfo', **host_options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/wechat/model/app/read_app.rb', line 10

def oauth2_url(scope = 'snsapi_userinfo', **host_options)
  options = Rails.application.routes.default_url_options
  h = {
    appid: appid,
    redirect_uri: url_helpers.app_url(id, **options),
    response_type: 'code',
    scope: scope,
    state: SecureRandom.hex(16)
  }
  "https://open.weixin.qq.com/connect/oauth2/authorize?#{h.to_query}#wechat_redirect"
end