本文整理匯總了Golang中github.com/garyburd/go-oauth/oauth.Credentials.Token方法的典型用法代碼示例。如果您正苦於以下問題:Golang Credentials.Token方法的具體用法?Golang Credentials.Token怎麽用?Golang Credentials.Token使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/garyburd/go-oauth/oauth.Credentials
的用法示例。
在下文中一共展示了Credentials.Token方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: signQuery
func (bs *BossSearch) signQuery(url string, values *url.Values) {
cred := oauth.Credentials{}
cred.Token = bs.Token
cred.Secret = bs.Secret
client := oauth.Client{}
client.SignatureMethod = oauth.HMACSHA1
client.Credentials = cred
client.SignForm(nil, "GET", url, *values)
}
示例2: ServeHTTP
func (h *authHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var cred oauth.Credentials
if err := getCookie(r, "auth", &cred); err != nil {
if err != http.ErrNoCookie {
http.Error(w, "Error reading auth cookie, "+err.Error(), 500)
return
}
cred.Token = ""
}
var pcred *oauth.Credentials
if cred.Token != "" && cred.Secret != "" {
pcred = &cred
}
if pcred == nil && !h.optional {
http.Error(w, "Not logged in.", 403)
return
}
h.handler(w, r, pcred)
}