【发布时间】:2018-08-03 07:29:51
【问题描述】:
我正在使用 Go,我想使用 Google API。 从doc,我找到了这个例子:
// Your credentials should be obtained from the Google
// Developer Console (https://console.developers.google.com).
conf := &oauth2.Config{
ClientID: "YOUR_CLIENT_ID",
ClientSecret: "YOUR_CLIENT_SECRET",
RedirectURL: "YOUR_REDIRECT_URL",
Scopes: []string{
"https://www.googleapis.com/auth/bigquery",
"https://www.googleapis.com/auth/blogger",
},
Endpoint: google.Endpoint,
}
// Redirect user to Google's consent page to ask for permission
// for the scopes specified above.
url := conf.AuthCodeURL("state")
fmt.Printf("Visit the URL for the auth dialog: %v", url)
// Handle the exchange code to initiate a transport.
tok, err := conf.Exchange(oauth2.NoContext, "authorization-code")
if err != nil {
log.Fatal(err)
}
client := conf.Client(oauth2.NoContext, tok)
client.Get("...")
我有两个问题:
-
redirect_url是什么?在开发者控制台中,我可以得到我的client_id和my client_secret,但我不知道redirect_url是什么。我在哪里可以找到它? -
authorization_code是什么?我在哪里可以找到它?
谢谢
【问题讨论】:
标签: go oauth-2.0 google-api token google-oauth