From 3c3cda7326f11b2bb8a2a57a3bc327285bf6b115 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 14 Apr 2014 05:07:19 -0400 Subject: [PATCH] Weibo oauth --- conf/app.ini | 12 ++++++++---- modules/social/social.go | 8 ++++++-- templates/base/head.tmpl | 1 - 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index c70919961..90ed0b5bc 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -98,16 +98,20 @@ ENABLED = false CLIENT_ID = CLIENT_SECRET = SCOPES = all -AUTH_URL = https://open.t.qq.com/cgi-bin/oauth2/authorize -TOKEN_URL = https://open.t.qq.com/cgi-bin/oauth2/access_token +AUTH_URL = https://graph.qq.com/oauth2.0/authorize +TOKEN_URL = https://graph.qq.com/oauth2.0/token [oauth.twitter] ENABLED = false CLIENT_ID = CLIENT_SECRET = SCOPES = all -AUTH_URL = https://api.twitter.com/oauth/authorize -TOKEN_URL = https://api.twitter.com/oauth/access_token +; Tencent weibo +AUTH_URL = https://open.t.qq.com/cgi-bin/oauth2/authorize +TOKEN_URL = https://open.t.qq.com/cgi-bin/oauth2/access_token +; QQ 互联 +; AUTH_URL = https://api.twitter.com/oauth/authorize +; TOKEN_URL = https://api.twitter.com/oauth/access_token [oauth.weibo] ENABLED = false diff --git a/modules/social/social.go b/modules/social/social.go index c2ee54177..5baa3c8d8 100644 --- a/modules/social/social.go +++ b/modules/social/social.go @@ -368,7 +368,7 @@ func (s *SocialWeibo) SetRedirectUrl(url string) { s.Transport.Config.RedirectURL = url } -func (s *SocialWeibo) UserInfo(token *oauth.Token, _ *url.URL) (*BasicUserInfo, error) { +func (s *SocialWeibo) UserInfo(token *oauth.Token, URL *url.URL) (*BasicUserInfo, error) { transport := &oauth.Transport{Token: token} var data struct { Id string `json:"id"` @@ -376,8 +376,12 @@ func (s *SocialWeibo) UserInfo(token *oauth.Token, _ *url.URL) (*BasicUserInfo, } var err error + var urls = url.Values{ + "access_token": {token.AccessToken}, + "uid": URL.Query()["uid"], + } reqUrl := "https://api.weibo.com/2/users/show.json" - r, err := transport.Client().Get(reqUrl) + r, err := transport.Client().Get(reqUrl + "?" + urls.Encode()) if err != nil { return nil, err } diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 109ddd353..68231391c 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -10,7 +10,6 @@ {{if .Repository.IsGoget}}{{end}} - {{if IsProdMode}}