private IAuthenticator Login(string pAuthorizationCode, string pEmail, string pState) { if (!String.IsNullOrEmpty(pAuthorizationCode)) { return(AuthenticationUtils.GetCredentials(pEmail, pAuthorizationCode, pState)); } else { IAuthorizationState authorizationState = AuthenticationUtils.GetStoredCredentials(pEmail); return(AuthenticationUtils.GetAuthenticatorFromState(authorizationState)); } }
static void Main(string[] args) { int i = 1; while (i != 0) { Console.WriteLine("Ingrese un numero"); i = Int32.Parse(Console.ReadLine()); if (i == 1) { Console.WriteLine("Ingrese el codigo de autorizacion"); string authCode = Console.ReadLine(); Console.WriteLine("Ingrese su mail"); string email = Console.ReadLine(); Console.WriteLine("Ingrese el texto a enviar"); string texto = Console.ReadLine(); TimelineItem item = new TimelineItem(); item.Text = texto; /* Puse el mail, pero puede ser cualquier cosa. Lo uso solo para identificar al usuario y poder acceder desp * a su correspondiente auth token y refresh token*/ IAuthenticator credentials = AuthenticationUtils.GetCredentials(email, authCode, "Sigo sin enteder pa que sirve esto"); //MirrorService service = BuildService(credentials); //service.Timeline.Insert(item).Fetch(); } else if (i == 2) { Console.WriteLine("Ingrese su mail"); string email = Console.ReadLine(); Console.WriteLine("Ingrese el texto a enviar"); string texto = Console.ReadLine(); Credential credential = GlassContext.Instancia.GetCredential(email); AuthorizationState state = new AuthorizationState() { AccessToken = credential.AccessToken, RefreshToken = credential.RefreshToken }; MirrorService service = BuildService(AuthenticationUtils.GetAuthenticatorFromState(state)); Image image = Image.FromFile("C:\\Users\\Guido\\Desktop\\1405290025332.jpg"); var ms = new MemoryStream(); image.Save(ms, ImageFormat.Jpeg); ms.Position = 0; TimelineItem itemAttachment = InsertTimelineItem(service, "Equipo argentino", "image/jpeg", ms, "DEFAULT"); } } }