How to authenticate with Google Drive in asp.net without copy/pasting auth tokens

一曲冷凌霜 提交于 2019-12-11 06:32:25

问题


I'm trying to get authorization code for Google Drive in my ASP program. I wrote some code like quickstart program from sample of Google API for .NET:

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);
}

I want to get authorization code by opening a popup and user can access permission in this, after user access permission, this return the code.

来源:https://stackoverflow.com/questions/13752727/how-to-authenticate-with-google-drive-in-asp-net-without-copy-pasting-auth-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!