我试图在我的ASP程序中获取Google云端硬盘的授权码。我从Google API for .NET样本中编写了一些类似quickstart程序的代码:
private static IAuthorizationState GetAuthorization(NativeApplicationClient arg){
// Get the auth URL:
IAuthorizationState state = new AuthorizationState(
new[] {DriveService.Scopes.Drive.GetStringValue() });
state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
Uri authUri = arg.RequestUserAuthorization(state);
//Request authorization from the user (by opening a browser window):
Process.Start(authUri.ToString());
Console.Write(" Authorization Code: ");
string authCode = Console.ReadLine();
Console.WriteLine();
// Retrieve the access token by using the authorization code:
return arg.ProcessUserAuthorization(authCode, state);
}
我想通过打开一个弹出窗口来获取授权码,用户可以在此访问权限,在用户访问权限之后,返回代码。