public override IStorageProviderSession CreateSession(ICloudStorageAccessToken token, ICloudStorageConfiguration configuration) { var skydriveToken = token as OAuth20Token; if (skydriveToken == null) { throw new ArgumentException("Cannot create skydrive session with given token", "token"); } if (skydriveToken.IsExpired) { token = SkyDriveAuthorizationHelper.RefreshToken(skydriveToken); } return(new SkyDriveStorageProviderSession(token, this, configuration)); }
private static OAuth20Token GetValidToken(IStorageProviderSession session) { var token = session.SessionToken as OAuth20Token; if (token == null) { throw new ArgumentException("Can not retrieve valid oAuth 2.0 token from given session", "session"); } if (token.IsExpired) { token = (OAuth20Token)SkyDriveAuthorizationHelper.RefreshToken(token); var sdSession = session as SkyDriveStorageProviderSession; if (sdSession != null) { sdSession.SessionToken = token; } } return(token); }
public void RefreshTokenTest() { var token = GetAccessToken(); var refreshed = SkyDriveAuthorizationHelper.RefreshToken(token); }