GetTokenForce is used to obtain a new token for the given kite. It always returns a new token and forces a Kontrol to forget about any previous ones.
(kite *protocol.Kite)
| 222 | // It always returns a new token and forces a Kontrol to |
| 223 | // forget about any previous ones. |
| 224 | func (k *Kite) GetTokenForce(kite *protocol.Kite) (string, error) { |
| 225 | if err := k.SetupKontrolClient(); err != nil { |
| 226 | return "", err |
| 227 | } |
| 228 | |
| 229 | <-k.kontrol.readyConnected |
| 230 | |
| 231 | args := &protocol.GetTokenArgs{ |
| 232 | KontrolQuery: *kite.Query(), |
| 233 | Force: true, |
| 234 | } |
| 235 | |
| 236 | result, err := k.kontrol.TellWithTimeout("getToken", k.Config.Timeout, args) |
| 237 | if err != nil { |
| 238 | return "", err |
| 239 | } |
| 240 | |
| 241 | var tkn string |
| 242 | err = result.Unmarshal(&tkn) |
| 243 | if err != nil { |
| 244 | return "", err |
| 245 | } |
| 246 | |
| 247 | return tkn, nil |
| 248 | } |
| 249 | |
| 250 | // GetKey is used to get a new public key from kontrol if the current one is |
| 251 | // invalidated. The key is also replaced in memory and every request is going |