Pregunta

He construido una aplicación Windows Phone 7 con una función "Iniciar sesión con Google".La biblioteca de Google no es compatible con Windows Phone Runtime, así que elijo RESTSHARP.

La aplicación ha recibido exitosamente un código de autenticación de Google, y el siguiente paso es intercambiar el código para un token de acceso y un token de actualización.Aquí me encontré con un problema.

var request = new RestRequest(this.TokenEndPoint, Method.POST);
request.AddParameter("code", code);
request.AddParameter("client_id", this.ClientId);
request.AddParameter("client_secret", this.Secret);
request.AddParameter("redirect_uri", "http://localhost");
request.AddParameter("grant_type", "authorization_code");
client.ExecuteAsync<???>(request, (response) =>
            {
                var passIn = response;
            }); // how to use this method?

No estoy seguro de cómo usar el método client.ExecuteAsync<T> (o cualquier otro ser de ayuda) para obtener la respuesta de Google.¿Hay algún otro código previamente solicitado para que utilice dicho método?¿Alguien me puede ayudar?

¿Fue útil?

Solución

You need to bind a UI element to display the response. That seems to be the gist of the problem you've outlined.

If you want to display the response in your application, you should have a UI element bound to an internal data structure.

Displaying the response

// in xaml, for example MainPage.xaml

<TextBox x:Name="myResponseTextBox">

// in the corresponding MainPage.xaml.cs

client.ExecuteAsync(request, (response) =>
{

   myResponseTextBox.text = response.Content; 

}); 

The Text box will display the result of the callback when it completes.

Otros consejos

try:

client.ExecuteAsync(request, (response) =>
{
    var dataToBeParsed = response.Content;
});
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top