0
我在一個Golang應用程序中工作,這個連接到一個Oauth2服務,現在我有刷新令牌,我需要獲取一個新的訪問令牌,我正在使用golang.org/x/oauth2
但wans't成功,所以還有,我失去了一些東西,目前我有:使用Golang Oauth2庫更新訪問令牌
refresh_token := "some_refresh_token"
var conf = oauth2.Config{
ClientID:MY_CLIENT,
ClientSecret:MY_CLIENT_SECRET,
Scopes:[]string{"refresh_token"},
RedirectURL:"https://mydomain/callback",
Endpoint: oauth2.Endpoint{
AuthURL:"myoauth2Cluster.com/oauth2/auth",
TokenURL: "myoauth2Cluster.com/oauth2/token",
},
}
t := new (oauth2.Token)
t.RefreshToken=refresh_token
myclient := conf.Client(context.Background(),t)
req, err := http.NewRequest("GET",DontKnowWhichURLhere , nil)
if err != nil {
fmt.Println("error:",err.Error())
}
mrr, er := myclient.Do(req)
if(er!=nil){
fmt.Println(er.Error())
}else{
fmt.Println("status code:",mrr.StatusCode)
}
但我得到一個404個狀態,我檢查的oauth2服務器的日誌,在那裏我有
msg="completed handling request" measure#https://myOauth2Cluster.latency=100648 method=GET remote=xxx.xxx.xx.xxx request="/" status=404 text_status="Not Found" took=100.648µs
此外,我不確定創建哪個網址時應創建http.NewRequest
它應該是一個回調?或Oauth2服務器的網址?
如果有,如何使用這個庫將是很好的更新訪問令牌的一些例子,但目前我還沒有發現它