我是新来的。 我无法使用c#.net Web客户端服务进行身份验证。 可能是我做错了什么。
{
"web": {
"client_id": "1078513092554-scaalvk0kmvivq9nrd6gag7gkhqud0l9.apps.googleusercontent.com",
"project_id": "claritysoft---go-1536637808216",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://www.googleapis.com/oauth2/v3/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "<My_Client_Secret>",
"redirect_uris": [ "http://localhost:51454/customize/dialogs/api_settings/googlecalendar.aspx" ],
"javascript_origins": [ "http://localhost:51454" ]
}
}
请注意: api控制台中的重定向URI为:- http://localhost:51454/customize/dialogs/api_settings/googlecalendar.aspx
public void LogIn()
{
string db = Common.DBName;
string userid = Common.LoggedInUserId;
UserCredential credential;
using (
var stream = new FileStream(SavedCredentialJsonPath,
FileMode.Open,
FileAccess.Read)
){
string credPath = SavedTokenPath
.Replace("{$DB_NAME$}",db.ToLower())
.Replace("{$USER_ID$}", userid.ToLower());
credential =
GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"projjwalkmaiti@gmail.com",
CancellationToken.None,
new FileDataStore(credPath, true)
).Result;
}
google_credentials = credential;
}
但是我从Google收到以下错误(错误代码400) 请求http://127.0.0.1:57014/authorize/中的重定向URI与为OAuth客户端授权的重定向URI不匹配。要更新授权的重定向URI,请访问:https://console.developers.google.com/apis/credentials/oauthclient/1078513092554-scaalvk0kmvivq9nrd6gag7gkhqud0l9.apps.googleusercontent.com?project=1078513092554
感谢您的帮助。 预先感谢!