Handling of expired tokens in cache, additional formatting of skills
This commit is contained in:
parent
74e6f41998
commit
4bdd6ac706
1 changed files with 14 additions and 8 deletions
22
main.go
22
main.go
|
@ -66,7 +66,15 @@ func main() {
|
|||
|
||||
client := googleOauthConfig.Client(oauth2.NoContext, cToken)
|
||||
|
||||
m := getCharacterInfo(client)
|
||||
m, err := getCharacterInfo(client)
|
||||
if err != nil {
|
||||
cToken = getNewAuthorizationToken()
|
||||
client = googleOauthConfig.Client(oauth2.NoContext, cToken)
|
||||
m, err = getCharacterInfo(client)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
fmt.Printf("Name: %s\n", m.CharacterName)
|
||||
fmt.Printf("Id: %d\n", m.CharacterID)
|
||||
|
||||
|
@ -75,13 +83,12 @@ func main() {
|
|||
getCharacterSkillQueue(client, m)
|
||||
}
|
||||
|
||||
func getCharacterInfo(client *http.Client) *Character {
|
||||
func getCharacterInfo(client *http.Client) (*Character, error) {
|
||||
|
||||
req, _ := http.NewRequest("GET", "https://login.eveonline.com/oauth/verify", nil)
|
||||
response, errDo := client.Do(req)
|
||||
if errDo != nil {
|
||||
fmt.Printf("Request error '%s'\n", errDo)
|
||||
return nil
|
||||
return nil, errDo
|
||||
}
|
||||
|
||||
defer response.Body.Close()
|
||||
|
@ -90,11 +97,10 @@ func getCharacterInfo(client *http.Client) *Character {
|
|||
var m Character
|
||||
errJSON := json.Unmarshal(contents, &m)
|
||||
if errJSON != nil {
|
||||
fmt.Printf("JSON read error with '%s'\n", errJSON)
|
||||
return nil
|
||||
return nil, errJSON
|
||||
}
|
||||
|
||||
return &m
|
||||
return &m, nil
|
||||
}
|
||||
|
||||
func getCharacterSkillQueue(client *http.Client, m *Character) {
|
||||
|
@ -165,7 +171,7 @@ func getCharacterSkillQueue(client *http.Client, m *Character) {
|
|||
continue
|
||||
}
|
||||
|
||||
fmt.Printf(" %s - level %d - %s to %s\n",
|
||||
fmt.Printf("% 35s - level %d - %s to %s\n",
|
||||
name,
|
||||
*skill.FinishedLevel,
|
||||
time.Time(skill.StartDate).Format("_2 Jan 2006, 15:04"),
|
||||
|
|
Reference in a new issue