add authtoken auth
This commit is contained in:
parent
8d81775809
commit
6a5df36aed
1 changed files with 12 additions and 15 deletions
25
auth.go
25
auth.go
|
|
@ -401,13 +401,14 @@ func (s *Scraper) SetCookies(cookies []*http.Cookie) {
|
||||||
s.client.Jar.SetCookies(twURL, cookies)
|
s.client.Jar.SetCookies(twURL, cookies)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scraper) SetAuthToken(authToken string, ct0 string) {
|
func (s *Scraper) ClearCookies() {
|
||||||
var (
|
s.client.Jar, _ = cookiejar.New(nil)
|
||||||
cookies []*http.Cookie
|
}
|
||||||
expires = time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC)
|
|
||||||
)
|
|
||||||
|
|
||||||
cookies = append(cookies, &http.Cookie{
|
// Auth using auth_token and ct0 cookies
|
||||||
|
func (s *Scraper) SetAuthToken(authToken string, ct0 string) {
|
||||||
|
expires := time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||||
|
cookies := []*http.Cookie{{
|
||||||
Name: "auth_token",
|
Name: "auth_token",
|
||||||
Value: authToken,
|
Value: authToken,
|
||||||
Path: "",
|
Path: "",
|
||||||
|
|
@ -419,9 +420,8 @@ func (s *Scraper) SetAuthToken(authToken string, ct0 string) {
|
||||||
HttpOnly: false,
|
HttpOnly: false,
|
||||||
SameSite: 0,
|
SameSite: 0,
|
||||||
Raw: "",
|
Raw: "",
|
||||||
})
|
Unparsed: nil,
|
||||||
|
}, {
|
||||||
cookies = append(cookies, &http.Cookie{
|
|
||||||
Name: "ct0",
|
Name: "ct0",
|
||||||
Value: ct0,
|
Value: ct0,
|
||||||
Path: "",
|
Path: "",
|
||||||
|
|
@ -433,15 +433,12 @@ func (s *Scraper) SetAuthToken(authToken string, ct0 string) {
|
||||||
HttpOnly: false,
|
HttpOnly: false,
|
||||||
SameSite: 0,
|
SameSite: 0,
|
||||||
Raw: "",
|
Raw: "",
|
||||||
})
|
Unparsed: nil,
|
||||||
|
}}
|
||||||
|
|
||||||
s.SetCookies(cookies)
|
s.SetCookies(cookies)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Scraper) ClearCookies() {
|
|
||||||
s.client.Jar, _ = cookiejar.New(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Scraper) sign(method string, ref *url.URL) string {
|
func (s *Scraper) sign(method string, ref *url.URL) string {
|
||||||
m := make(map[string]string)
|
m := make(map[string]string)
|
||||||
m["oauth_consumer_key"] = appConsumerKey
|
m["oauth_consumer_key"] = appConsumerKey
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue