@@ -17,17 +17,28 @@ func main() {
17
17
fmt .Println ("将跳转浏览器授权" )
18
18
fmt .Println ("请输入App的应用程序(客户端) ID [Client Id]" )
19
19
clientId := readLine ()
20
- err := OpenBrowser (BuildMsAuthorizeUrl (clientId ))
20
+ fmt .Println ("请输入App的API权限,并使用空格隔开" )
21
+ fmt .Println ("如果为空则默认为(offline_access Files.Read Files.Read.All Files.ReadWrite Files.ReadWrite.All)" )
22
+ permission := readLine ()
23
+ if len (permission ) == 0 {
24
+ permission = "offline_access Files.Read Files.Read.All Files.ReadWrite Files.ReadWrite.All"
25
+ fmt .Printf ("输入为空,已使用默认设置" )
26
+ fmt .Println ()
27
+ }
28
+ err := OpenBrowser (BuildMsAuthorizeUrl (clientId , permission ))
21
29
if err != nil {
22
30
fmt .Printf ("启动浏览器时发生错误\r \n %s" , err .Error ())
31
+ readLine ()
32
+ return
23
33
}
24
34
fmt .Println ()
25
35
clientCode := <- CodeCh
26
36
if clientCode != nil {
27
- fmt .Printf ("获取到code(%v)\r \n " , len (* clientCode ))
37
+ fmt .Printf ("获取到code(%v)" , len (* clientCode ))
38
+ fmt .Println ()
28
39
} else {
29
40
fmt .Println ("获取code失败,请检查client_id和网络设置" )
30
- _ = readLine ()
41
+ readLine ()
31
42
return
32
43
}
33
44
fmt .Println ()
@@ -40,8 +51,10 @@ func main() {
40
51
_ = readLine ()
41
52
return
42
53
}
43
- fmt .Printf ("获取到token(%v)\r \n " , len (tokenData .AccessToken ))
44
- fmt .Printf ("获取到refresh-token(%v)\r \n " , len (tokenData .RefreshToken ))
54
+ fmt .Printf ("获取到token(%v)" , len (tokenData .AccessToken ))
55
+ fmt .Println ()
56
+ fmt .Printf ("获取到refresh-token(%v)" , len (tokenData .RefreshToken ))
57
+ fmt .Println ()
45
58
saveData := TokenResult {
46
59
ClientId : clientId ,
47
60
ClientCode : * clientCode ,
@@ -69,12 +82,12 @@ func readLine() (str string) {
69
82
70
83
func initLog () {
71
84
fmt .Println ("Ciallo~(∠・ω< )⌒☆" )
72
- fmt .Println ("本工具将帮助你获取微软Graph的API的访问令牌,获取到的结果将保存到工具运行的目录下" )
85
+ fmt .Println ("本工具将帮助你获取微软Graph的API的访问令牌,获取到的结果将保存到工具运行的目录下(默认将选择OneDriver相关权限) " )
73
86
fmt .Println ()
74
- fmt .Println ("请先保证使用本工具前已经在Microsoft Azure重创建了新的应用 ,并满足以下条件:" )
75
- fmt .Println ("1.并授予了offline_access Files.Read Files.Read.All Files.ReadWrite Files.ReadWrite.All权限 " )
76
- fmt .Println ("2.重定向URL选择了(Web)类型,并设置值为(http://localhost:11451/auth )" )
77
- fmt .Println ("3.在证书和密码选项卡中创建并保存了机密值(Client Secret )" )
87
+ fmt .Println ("请先保证使用本工具前已经在Microsoft Azure中创建了新的应用 ,并满足以下条件:" )
88
+ fmt .Println ("1.重定向URL选择了(Web)类型,并设置值为(http://localhost:11451/auth) " )
89
+ fmt .Println ("2.在证书和密码选项卡中创建并保存了机密值(Client Secret )" )
90
+ fmt .Println ("如果需要使用OneDriver相关API(如各种网盘列表),请在API权限中授权(offline_access Files.Read Files.Read.All Files.ReadWrite Files.ReadWrite.All )" )
78
91
fmt .Println ("请在确认以上条件后按回车继续" )
79
92
_ = readLine ()
80
93
}
0 commit comments