我想在没有用户登录帐户的情况下嵌入api。我是google api的新手,我想使用embed api Like this one 我从昨天开始一直在寻找如何通过javascript或.net实现这一点。
我在.net
中有这段代码 string keyFilePath = Server.MapPath("~/Libraries/googleKey/key.json");
string json = System.IO.File.ReadAllText(keyFilePath);
var cr = JsonConvert.DeserializeObject<PersonalServiceAccountCred>(json);
var xCred = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(cr.client_email)
{
Scopes = new[] {
AnalyticsReportingService.Scope.AnalyticsReadonly
}
}.FromPrivateKey(cr.private_key));
我得到一个空令牌,我很困惑,大多数例子都是php或python。
答案 0 :(得分:1)
您可以使用服务帐户,确保您已获得授予服务帐户的访问权限