forked from NYANDEV/forgejo
Weibo oauth
This commit is contained in:
parent
c3c2cfebaa
commit
3c3cda7326
3 changed files with 14 additions and 7 deletions
12
conf/app.ini
12
conf/app.ini
|
@ -98,16 +98,20 @@ ENABLED = false
|
||||||
CLIENT_ID =
|
CLIENT_ID =
|
||||||
CLIENT_SECRET =
|
CLIENT_SECRET =
|
||||||
SCOPES = all
|
SCOPES = all
|
||||||
AUTH_URL = https://open.t.qq.com/cgi-bin/oauth2/authorize
|
AUTH_URL = https://graph.qq.com/oauth2.0/authorize
|
||||||
TOKEN_URL = https://open.t.qq.com/cgi-bin/oauth2/access_token
|
TOKEN_URL = https://graph.qq.com/oauth2.0/token
|
||||||
|
|
||||||
[oauth.twitter]
|
[oauth.twitter]
|
||||||
ENABLED = false
|
ENABLED = false
|
||||||
CLIENT_ID =
|
CLIENT_ID =
|
||||||
CLIENT_SECRET =
|
CLIENT_SECRET =
|
||||||
SCOPES = all
|
SCOPES = all
|
||||||
AUTH_URL = https://api.twitter.com/oauth/authorize
|
; Tencent weibo
|
||||||
TOKEN_URL = https://api.twitter.com/oauth/access_token
|
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]
|
[oauth.weibo]
|
||||||
ENABLED = false
|
ENABLED = false
|
||||||
|
|
|
@ -368,7 +368,7 @@ func (s *SocialWeibo) SetRedirectUrl(url string) {
|
||||||
s.Transport.Config.RedirectURL = url
|
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}
|
transport := &oauth.Transport{Token: token}
|
||||||
var data struct {
|
var data struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
|
@ -376,8 +376,12 @@ func (s *SocialWeibo) UserInfo(token *oauth.Token, _ *url.URL) (*BasicUserInfo,
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
var urls = url.Values{
|
||||||
|
"access_token": {token.AccessToken},
|
||||||
|
"uid": URL.Query()["uid"],
|
||||||
|
}
|
||||||
reqUrl := "https://api.weibo.com/2/users/show.json"
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
<meta name="keywords" content="go, git">
|
<meta name="keywords" content="go, git">
|
||||||
<meta name="_csrf" content="{{.CsrfToken}}" />
|
<meta name="_csrf" content="{{.CsrfToken}}" />
|
||||||
{{if .Repository.IsGoget}}<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}">{{end}}
|
{{if .Repository.IsGoget}}<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}">{{end}}
|
||||||
<meta property="qc:admins" content="34543312371436727" />
|
|
||||||
|
|
||||||
<!-- Stylesheets -->
|
<!-- Stylesheets -->
|
||||||
{{if IsProdMode}}
|
{{if IsProdMode}}
|
||||||
|
|
Loading…
Reference in a new issue