0

I need to upload file in Google Drive using g-suite. I am getting a "Authorization Error" error like this:

The redirect URI in the request, http://127.0.0.1:62990/authorize/, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: https://console.developers.google.com/apis/credentials/oauthclient/832895456388-gi5bqd65lnfk116es7lp3coes2o724s4.apps.googleusercontent.com?project=832895456388

This is detail of my Keys:

Details

And here is code:

   public ActionResult UploadFiles()
        {
            GSuiteCredentials gSuiteCredentials = new GSuiteCredentials();
            string serverPath = Server.MapPath("/Content/Gsuite/");
            string UserPath = Server.MapPath("/Content/Gsuite/67/client_secret_352975997152-cs82i5rbhe50b7n2m0bk2gut8dlm9sq4.apps.googleusercontent.com.json");
            var service = new DriveService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = gSuiteCredentials.GetCredentials(serverPath, UserPath, "781"),
            });
            string uname = Request["uploadername"];
            HttpFileCollectionBase files = Request.Files;
            for (int i = 0; i < files.Count; i++)
            {
                HttpPostedFileBase file = files[i];
                string fname;
                // Checking for Internet Explorer      
                if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                {string[] testfiles = file.FileName.Split(new char[] { '\\' });
                    fname = testfiles[testfiles.Length - 1];}
                else{fname = file.FileName;}
                string fname1 = fname;
                fname = Path.Combine(Server.MapPath("~/Uploads/"), fname);
                file.SaveAs(fname);
                gSuiteCredentials.UploadAdvance(Path.Combine(Server.MapPath("~/Uploads/"+ fname1)), service);
            }
            return Json("Hi, " + uname + ". Your files uploaded successfully", JsonRequestBehavior.AllowGet);
        }

API's keys

enter image description here

  • You do realise you posted part of your credentials in that screenshot? – Panagiotis Kanavos Jul 15 '20 at 08:59
  • You *already* posted the full ClientID when you posted that URL. You already posted parts of the secret in the original screenshot, now you posted the rest – Panagiotis Kanavos Jul 15 '20 at 09:08
  • i ll delete this key after solve this isses –  Jul 15 '20 at 09:11
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/217889/discussion-between-faizan-hazma-and-panagiotis-kanavos). –  Jul 15 '20 at 09:54
  • Does this answer your question? [Google OAuth 2 authorization - Error: redirect\_uri\_mismatch](https://stackoverflow.com/questions/11485271/google-oauth-2-authorization-error-redirect-uri-mismatch) – Iamblichus Jul 15 '20 at 10:33
  • NO. i already see this . –  Jul 15 '20 at 12:02

0 Answers0