Google+ API を使用して、認証済みユーザーの情報にアクセスしようとしています。サンプルの 1 つからいくつかのコードをコピーしましたが、正常に動作します (以下)。
「RefreshToken」プロパティをキャプチャしてprovider.RefreshToken()
(とりわけ)使用してみましたが、常に400 Bad Request
応答が得られます。
誰かがこれを機能させる方法を知っていますか、またはいくつかのサンプルを見つけることができる場所を知っていますか? Googleコードサイトはこれをカバーしていないようです:-(
class Program
{
private const string Scope = "https://www.googleapis.com/auth/plus.me";
static void Main(string[] args)
{
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
provider.ClientIdentifier = "BLAH";
provider.ClientSecret = "BLAH";
var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthentication);
var plus = new PlusService(auth);
plus.Key = "BLAH";
var me = plus.People.Get("me").Fetch();
Console.WriteLine(me.DisplayName);
}
private static IAuthorizationState GetAuthentication(NativeApplicationClient arg)
{
// Get the auth URL:
IAuthorizationState state = new AuthorizationState(new[] { Scope });
state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
Uri authUri = arg.RequestUserAuthorization(state);
// Request authorization from the user (by opening a browser window):
Process.Start(authUri.ToString());
Console.Write(" Authorization Code: ");
string authCode = Console.ReadLine();
Console.WriteLine();
// Retrieve the access token by using the authorization code:
return arg.ProcessUserAuthorization(authCode, state);
}
}