我在哪里错了?当我尝试URL时,它说:"缺少必需参数:response_type"。为了让这个东西起作用,我需要添加什么?如果你能提供一个很棒的简单解释。
string client_ID = "XXXXXXX";
string client_Secret = "XXXXXXXXXXX";
string scope = "https://apps-apis.google.com/a/feeds/emailsettings/2.0/workwearoutlet.co.uk/zak.baig/signature";
string redirect_URI = "urn:ietf:wg:oauth:2.0:oob";
// Prepare OAuth parameters
OAuth2Parameters parameters = new OAuth2Parameters();
parameters.ClientId = client_ID;
parameters.ClientSecret = client_Secret;
parameters.Scope = scope;
parameters.RedirectUri = redirect_URI;
string applicationName = "signature";
string domain = "workwearoutlet.co.uk";
// Request authorization from the user
string authorizationURL = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
Console.WriteLine(authorizationURL);
Console.WriteLine("Please visit the URL above to authorize your OAuth " +
"request token. Once that is complete, type in your access code to " +
"continue...");
parameters.AccessCode = Console.ReadLine();
OAuthUtil.GetAccessToken(parameters);
string accessToken = parameters.AccessToken;
Console.WriteLine("OAuth Access Token: " + accessToken);
try
{
// Create a new request factory so it uses our OAuth credentials
GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory("apps", applicationName, parameters);
GoogleMailSettingsService service = new GoogleMailSettingsService(domain, applicationName);
service.RequestFactory = requestFactory;
// Update the signature for the user testUserName
service.UpdateSignature("zak.baig@workwearoutlet.co.uk", "My tiny signature");
Console.WriteLine(service.RetrieveSignature("zak.baig@workwearoutlet.co.uk"));
}
catch (AppsException a)
{
Console.WriteLine("A Google Apps error occurred.");
Console.WriteLine();
Console.WriteLine("Error code: {0}", a.ErrorCode);
Console.WriteLine("Invalid input: {0}", a.InvalidInput);
Console.WriteLine("Reason: {0}", a.Reason);
}
答案 0 :(得分:-4)
我相信使用PHP OAuth2 API可以最好地实现这一目标。
这消除了编写错误的C#API调用函数的所有问题。
另外,您是否尝试过搜索功能?我发现了这个问题的多个修复程序。