We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b9d4334 commit f223ed5Copy full SHA for f223ed5
1 file changed
tokenOp.go
@@ -2,17 +2,31 @@ package networkutil
2
3
import (
4
"net/http"
5
+ "net/url"
6
+ "strings"
7
)
8
9
type TokenOperation struct {
10
CookieOp CookieOperation
11
}
12
-func NewTokenOp(domain string) *TokenOperation {
13
+// Create tokenOp.
14
+//
15
+// Arguments;
16
+// apiUrl {string} - URL of the API you are using.
17
+func NewTokenOp(apiUrl string) (*TokenOperation, error) {
18
+ u, err := url.Parse(apiUrl)
19
+ if err != nil {
20
+ return nil, err
21
+ }
22
+ splittedHost := strings.Split(u.String(), ".")
23
+ hostLen := len(splittedHost)
24
+ domain := strings.Join(splittedHost[hostLen-2:], ".")
25
+
26
cookieOp := NewCookieOp(domain)
27
return &TokenOperation{
28
CookieOp: *cookieOp,
- }
29
+ }, nil
30
31
32
// Set the refresh token.
0 commit comments