Skip to content

Instantly share code, notes, and snippets.

@yutannihilation
Created March 20, 2017 10:43
Show Gist options
  • Select an option

  • Save yutannihilation/8638417b71b361abfee7439bb07db883 to your computer and use it in GitHub Desktop.

Select an option

Save yutannihilation/8638417b71b361abfee7439bb07db883 to your computer and use it in GitHub Desktop.
TokenSony <- R6::R6Class("TokenSony", inherit = Token2.0, list(
init_credentials = function() {
super$init_credentials()
# expires_inは秒数なので、POSIXctにしておく
self$credentials$expires_timestamp <- Sys.time() + self$credentials$expires_in
},
refresh = function() {
super$refresh()
self$credentials$expires_timestamp <- Sys.time() + self$credentials$expires_in
},
sign = function(method, url) {
# 現在時刻がexpiresを超えていたらいったんrefresh()
if(Sys.time() > self$credentials$expires_timestamp) self$refresh()
super$sign(method, url)
}
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment