I have built a windows phone 7 app with a "sign in with google" function. Google library is not compatible with windows phone runtime so I choose RestSharp.
The app has successfully received a authentication code from Google, and the next step is to exchange the code for an access token and a refresh token. Here I encountered some problem.
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?
I'm not sure how to use the client.ExecuteAsync<T>
method (or any other would be helpful) to get the response from Google. Is there any other code pre-requested for me to use such method? Can anybody help me?
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.
try:
client.ExecuteAsync(request, (response) =>
{
var dataToBeParsed = response.Content;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With