From 8ce5c9ad91dc5ae2e2111bb4d0abd939b88c1d3c Mon Sep 17 00:00:00 2001 From: yafeilee Date: Mon, 26 Aug 2019 15:32:14 +0800 Subject: [PATCH 1/3] update url --- README.md | 9 +++------ lib/omniauth/strategies/wechat.rb | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b2878f3..6f7462a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Here's an example for adding the middleware to a Rails app in `config/initialize ```ruby Rails.application.config.middleware.use OmniAuth::Builder do - provider :wechat, ENV["WECHAT_APP_ID"], ENV["WECHAT_APP_SECRET"] + provider :wechat, ENV["WECHAT_APP_ID"], ENV["WECHAT_APP_SECRET"], scope: 'snsapi_userinfo' end ``` @@ -76,7 +76,8 @@ Here's an example of an authentication hash available in the callback by accessi }, :extra => { :raw_info => { - openid: "openid" + unionid: "unionid", # if exist + openid: "openid", nickname: "Nickname", sex: 1, province: "Changning", @@ -87,7 +88,3 @@ Here's an example of an authentication hash available in the callback by accessi } } ``` - - - - diff --git a/lib/omniauth/strategies/wechat.rb b/lib/omniauth/strategies/wechat.rb index 6f166e5..bb9af1f 100644 --- a/lib/omniauth/strategies/wechat.rb +++ b/lib/omniauth/strategies/wechat.rb @@ -7,7 +7,7 @@ class Wechat < OmniAuth::Strategies::OAuth2 option :client_options, { site: "https://api.weixin.qq.com", - authorize_url: "https://open.weixin.qq.com/connect/qrconnect?#wechat_redirect", + authorize_url: "https://open.weixin.qq.com/connect/oauth2/authorize?#wechat_redirect", token_url: "/sns/oauth2/access_token", token_method: :get } From f68533f21265dd85ca38c0f8cb4b00ae480a7a61 Mon Sep 17 00:00:00 2001 From: windy Date: Fri, 30 Aug 2019 16:54:58 +0800 Subject: [PATCH 2/3] Fix spec error --- README.md | 2 +- spec/omniauth/strategies/wechat_spec.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6f7462a..c5589c9 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Here's an example of an authentication hash available in the callback by accessi }, :extra => { :raw_info => { - unionid: "unionid", # if exist + unionid: "unionid", # if exist openid: "openid", nickname: "Nickname", sex: 1, diff --git a/spec/omniauth/strategies/wechat_spec.rb b/spec/omniauth/strategies/wechat_spec.rb index 7418d3e..62b49a2 100644 --- a/spec/omniauth/strategies/wechat_spec.rb +++ b/spec/omniauth/strategies/wechat_spec.rb @@ -27,7 +27,7 @@ end specify 'has authorize_url' do - expect(subject.client.options[:authorize_url]).to eq('https://open.weixin.qq.com/connect/qrconnect?#wechat_redirect') + expect(subject.client.options[:authorize_url]).to eq('https://open.weixin.qq.com/connect/oauth2/authorize?#wechat_redirect') end specify 'has token_url' do @@ -99,8 +99,8 @@ context "when scope is snsapi_base" do let(:access_token) { OAuth2::AccessToken.from_hash(client, { - "openid"=>"openid", - "scope"=>"snsapi_base", + "openid"=>"openid", + "scope"=>"snsapi_base", "access_token"=>"access_token" })} @@ -112,8 +112,8 @@ context "when scope is snsapi_userinfo" do let(:access_token) { OAuth2::AccessToken.from_hash(client, { - "openid"=>"openid", - "scope"=>"snsapi_userinfo", + "openid"=>"openid", + "scope"=>"snsapi_userinfo", "access_token"=>"access_token" })} @@ -147,4 +147,4 @@ -end \ No newline at end of file +end From e6cd6fabedaedf2a01f18571f77a4e40b459bd4a Mon Sep 17 00:00:00 2001 From: windy Date: Thu, 5 Sep 2019 17:02:28 +0800 Subject: [PATCH 3/3] fix space --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c5589c9..e558c79 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Here's an example of an authentication hash available in the callback by accessi }, :extra => { :raw_info => { - unionid: "unionid", # if exist + unionid: "unionid", #if exist openid: "openid", nickname: "Nickname", sex: 1,