是否可以通过Google API从用户的个人资料中获取信息?如果可能,我应该使用哪个API?
我对这些信息感兴趣:
从用户的个人资料中获取其他信息也很酷.
我创建了一个项目console.developers.google.com使用Google Calendar API.我们需要生成凭证并选择应用程序类型
对于Localhost和应用程序类型,other以下是可行的Json.
{
"installed": {
"client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
"project_id": "xxxxxx-00000",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "xxxxxxxxxxxx",
"redirect_uris": [ "urn:ietf:wg:oauth:2.0:oob", "http://localhost" ]
}
}
Run Code Online (Sandbox Code Playgroud)
对于Web Application服务器上的主机应用程序类型少数参数具有不同的值,Json如下所示.
{
"web": {
"client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
"project_id": "xxxxxxxx-99999",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "xxxxxxxxxxxxxxxxxxxxxxx",
"redirect_uris": [ "http://demo.mydemo.com" ],
"javascript_origins": [ "http://demo.mydemo.com" ]
}
}
Run Code Online (Sandbox Code Playgroud)
此处,当用户(仅限已集成Google日历的用户)尝试创建活动时,Google应同意使用哪个Google帐户,并要求在重定向到重定向页面之前阅读个人数据.在同意后,它将在所选谷歌帐户的日历中添加提供的数据.问题是它没有将用户重定向到Oauth身份验证即The Consent Screen.
错误如下
System.AggregateException: One or more errors occurred. …Run Code Online (Sandbox Code Playgroud) c# asp.net-mvc google-calendar-api google-oauth google-api-dotnet-client
我正在使用Google Calendar Api我的一个项目。我不知道如何,但下面显示的错误令人不安。
里面的代码AppFlowMetadata。
public class AppFlowMetadata : FlowMetadata
{
private static readonly IAuthorizationCodeFlow flow =
new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
{
ClientSecrets = new ClientSecrets
{
ClientId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
ClientSecret = "xxxxx_xxxxxxxxxxxxxxxxx"
},
Scopes = new[] { CalendarService.Scope.Calendar },
DataStore = new FileDataStore("Calendar.Api.Auth.Store")
});
public override string GetUserId(Controller controller)
{
var user = controller.Session["UserID"];
if (user == null)
{
user = Guid.NewGuid();
controller.Session["UserID"] = user;
}
return user.ToString();
}
public override IAuthorizationCodeFlow Flow
{
get { return …Run Code Online (Sandbox Code Playgroud)