Google Api GameService 没有个别错误 - .NET
Google Api GameService No individual errors - .NET
我正在尝试使用 GameService API 列出游戏 AchievementDefinitions,但总是 return [500] 没有个别错误。我使用 ServiceAccountCredential 进行身份验证。
我尝试了两种授权方式
string credPath = @"C:\Downloads\game-bd201016b65f.json";
var json = File.ReadAllText(credPath);
var cr = JsonConvert.DeserializeObject<dynamic>(json);
var xCred = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(cr.client_email.ToString())
{
Scopes = new[] { GamesService.Scope.Games }
}.FromPrivateKey(cr.private_key.ToString()));
var initializer = new BaseClientService.Initializer()
{
HttpClientInitializer = xCred
};
GamesService gamesService = new GamesService(initializer);
var a = gamesService.AchievementDefinitions.List().Execute();
和
GoogleCredential credential;
using (var stream = new FileStream(@"C:\game-bd201016b65f.json", FileMode.Open, FileAccess.Read, FileShare.Read))
{
credential = GoogleCredential.FromStream(stream);
}
if (credential.IsCreateScopedRequired)
{
credential = credential.CreateScoped(GamesService.Scope.Games);
}
var initializer = new BaseClientService.Initializer()
{
HttpClientInitializer = credential
};
在 .NET 中 运行 时会出现 API 错误吗?
GameServiceAPI用于获取用户认证信息,我需要的是获取Game信息,获取游戏信息需要使用GameServiceManagementAPI。
使用 GameService Management API 我可以使用 ServiceAccountCredential 进行身份验证并获取游戏信息。
我正在尝试使用 GameService API 列出游戏 AchievementDefinitions,但总是 return [500] 没有个别错误。我使用 ServiceAccountCredential 进行身份验证。
我尝试了两种授权方式
string credPath = @"C:\Downloads\game-bd201016b65f.json";
var json = File.ReadAllText(credPath);
var cr = JsonConvert.DeserializeObject<dynamic>(json);
var xCred = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(cr.client_email.ToString())
{
Scopes = new[] { GamesService.Scope.Games }
}.FromPrivateKey(cr.private_key.ToString()));
var initializer = new BaseClientService.Initializer()
{
HttpClientInitializer = xCred
};
GamesService gamesService = new GamesService(initializer);
var a = gamesService.AchievementDefinitions.List().Execute();
和
GoogleCredential credential;
using (var stream = new FileStream(@"C:\game-bd201016b65f.json", FileMode.Open, FileAccess.Read, FileShare.Read))
{
credential = GoogleCredential.FromStream(stream);
}
if (credential.IsCreateScopedRequired)
{
credential = credential.CreateScoped(GamesService.Scope.Games);
}
var initializer = new BaseClientService.Initializer()
{
HttpClientInitializer = credential
};
在 .NET 中 运行 时会出现 API 错误吗?
GameServiceAPI用于获取用户认证信息,我需要的是获取Game信息,获取游戏信息需要使用GameServiceManagementAPI。 使用 GameService Management API 我可以使用 ServiceAccountCredential 进行身份验证并获取游戏信息。