コード例 #1
0
func getOauthToken(verifier string, authChan chan Auth.AuthStageResult, bot *Auth.EvernoteAuthBot) {
    go bot.GetOauthToken(bot.TempOauthToken(), verifier, authChan)

    select {
        case result:=<-authChan:
            if result.Error != nil {
                handleErrors(result.Error, result.ErrorAssocObject)
            } else {
                switch v:=result.Elements["oauthToken"].(type) {
                    case string:
                        log.Printf("Got the token! %v", v)
                    default:
                        log.Fatal("Huge error, no token")
                }
            }
    }
}
コード例 #2
0
func allowAccess(authChan chan Auth.AuthStageResult, bot *Auth.EvernoteAuthBot) {

    log.Print("getting auth token")
    go bot.AllowAccess(bot.TempOauthToken(), authChan)

    select {
        case result:= <-authChan:
            if result.Error != nil {
                handleErrors(result.Error, result.ErrorAssocObject)
            } else {
                switch v := result.Elements["verifier"].(type) {
                    case string:
                        log.Print("getting oauth token")
                        getOauthToken(v, authChan, bot)
                    default:
                        log.Fatal("No verifier returned")
                }
            }
    }
}