Google 인증을 위해 RESTSHARP를 사용하는 방법은 무엇입니까?
-
14-11-2019 - |
문제
I "Google에 로그인"기능이있는 Windows Phone 7 응용 프로그램을 구축했습니다.Google 라이브러리는 Windows Phone 런타임과 호환되지 않으므로 RESTSHARP를 선택합니다.
앱은 Google에서 인증 코드를 성공적으로 받았으며 다음 단계는 액세스 토큰 및 새로 고침 토큰의 코드를 교환하는 것입니다.여기에서 몇 가지 문제가 발생했습니다.
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?
.
Google의 응답을 얻기 위해 client.ExecuteAsync<T>
메소드 (또는 다른 기타 도움이 될 수 있음)를 사용하는 방법을 모르겠습니다.그러한 방법을 사용하기 위해 사전 요청 된 다른 코드가 있습니까?아무도 나를 도와 줄 수 있습니까?
해결책
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;
});