Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to authenticate Google Drive in asp.net without copy/pasting auth tokens
    primarykey
    data
    text
    <p>I am developing Web Application to Upload a file on Google Drive in ASP.NET using C#.</p> <p>While running the Application I want to upload file automatically to Google Drive with automatic authentication technique. Following is the class file used to upload file but unable to authenticate to Google API.There is something Wrong with GetAuthorization(). Please help me for that...</p> <blockquote> <pre><code> namespace Cloud { class Code { private static readonly string CLIENT_ID = "303453771054- 4ftp53uun2o6jeiii85i22muc4fio76f.apps.googleusercontent.com"; private static readonly string CLIENT_SECRET = "wMc6mptgMTOL1ncGSJX-qoPS"; private static readonly string APIKEY = "AIzaSyAVyZF8OVl4Vvrbu9pWUQCzx35afdpYJR0"; private static readonly string REDIRECTURI = "http://localhost:49632/CloudCode.aspx"; private static readonly string[] SCOPES = new[] { DriveService.Scopes.Drive.GetStringValue() }; public void Main(string Filename) { var provider = new WebServerClient(GoogleAuthenticationServer.Description, CLIENT_ID, CLIENT_SECRET); provider.ClientIdentifier = CLIENT_ID; provider.ClientSecret = CLIENT_SECRET; provider.RequestUserAuthorization(); provider.ProcessUserAuthorization(null); var authenticator = new OAuth2Authenticator&lt;WebServerClient&gt;(provider, GetAuthorization); File body = new File(); body.Title = "My document"; body.Description = "A test document"; body.MimeType = "text/plain"; body.OriginalFilename = Filename; byte[] byteArray = System.IO.File.ReadAllBytes(body.OriginalFilename.ToString()); System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray); DriveService service = new DriveService(); FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, "text/plain"); request.Upload(); File file = request.ResponseBody; } private IAuthorizationState GetAuthorization(WebServerClient arg) { IAuthorizationState state = arg.ProcessUserAuthorization(new HttpRequestInfo(HttpContext.Current.Request)); IAuthorizationState AuthorizationState=new AuthorizationState(SCOPES); AuthorizationState.Callback = new Uri(REDIRECTURI); return AuthorizationState; } </code></pre> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload