Reputation: 717
I'm doing project in MVC C#, and working Google Drive Api.
I was on the site daimto.com and I took the samples and put in my MVC application. In site https://console.developers.google.com/apis/ and create two credencias:
The license for name Cliente Padrão works locally, the license Site SESMT should run on the server, but to access the page that has the release access, the site is thinking and thinking goes nowhere, it seems caught . My license to use on the server is as follows:
I've looked examples on the internet, but it's all for local application and nothing for Web application. I'm thinking that something is missing.
My page is thinking and thinking goes nowhere and does not show the authorization screen. Funny that in my local environment works
public static DriveService AuthenticateOauth(string clientId, string clientSecret, string userName)
{
string[] scopes = new string[] { DriveService.Scope.Drive, // view and manage your files and documents
DriveService.Scope.DriveAppdata, // view and manage its own configuration data
DriveService.Scope.DriveAppsReadonly, // view your drive apps
DriveService.Scope.DriveFile, // view and manage files created by this app
DriveService.Scope.DriveMetadataReadonly, // view metadata for files
DriveService.Scope.DriveReadonly, // view files and documents on your drive
DriveService.Scope.DriveScripts }; // modify your app scripts
var folder = System.Web.HttpContext.Current.Server.MapPath("/App_Data/GoogleDriveApi");
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret }
, scopes
, userName
, CancellationToken.None
, new FileDataStore(folder)).Result;
DriveService service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "site-sesmt"
});
return service;
}
public ActionResult Index()
{
string CLIENT_ID = "***.apps.googleusercontent.com";
string CLIENT_SECRET = "***";
DriveService service = GoogleApi.AuthenticateOauth(CLIENT_ID, CLIENT_SECRET, "portalsesmt");
return View();
}
Upvotes: 1
Views: 1938
Reputation: 102
I've encountered a similar problem a few weeks back when I was doing the exact same thing. If you are using Oauth 2.0, you have to enable the Google+ API in Google API Console->Dashboard->Enable API->Google+ API.
At least this solved the problem for me for some reason. I think google changed their APIs or something. Try that out and let me know if it worked.
Upvotes: 1