Created
November 29, 2011 16:57
-
-
Save jacquescrocker/1405523 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# update token data from an OAuth2::AccessToken | |
def from_token!(token) | |
new_token_data = { | |
"token" => token.token, | |
"expires_in" => token.expires_in, | |
"expires_at" => token.expires_at, | |
} | |
# add back refresh token | |
if token.refresh_token.present? | |
new_token_data["refresh_token"] = token.refresh_token | |
else | |
new_token_data["refresh_token"] = self.token_data["refresh_token"] | |
end | |
if persisted? | |
update_document({ | |
"$set" => { | |
"token_data" => new_token_data, | |
} | |
}, true) | |
else | |
self.token_data = new_token_data | |
end | |
new_token_data | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment