title: ASP.net Web Application (Not MVC): Accessing Google GoogleWebAuthorizationBroker.AuthorizeAsync returns access denied error
body: <p>Environment: ASP.NET simple web application on .net 4.5.1 integrated pipeline running on iis8 on server 2012 which is not following MVC.</p>
  
  <p>I'm attempting to get credentials from google's GoogleWebAuthorizationBroker but i keep getting "access is denied"...Even i allowed my urls in "Authorized JavaScript origins" and "Authorized redirect URIs"</p>
  
  <p>Following below URL implementation for Installed App
  <a href="https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#installed-applications" rel="nofollow">https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#installed-applications</a></p>
  
  <p>Here are mine code snippet</p>
  
  <pre><code>var folder = "F:\\MyApp\\WebApp\\MyGoogleStorage";
  
  string[] scopes = new string[] {
              Google.Apis.Proximitybeacon.v1beta1.ProximitybeaconService.Scope.UserlocationBeaconRegistry
          };
  
          ClientSecrets secrets = new ClientSecrets()
          {
              ClientId = CLIENT_ID,
              ClientSecret = CLIENT_SECRET
          };
  
  UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                          secrets,
                          scopes,
                          "user",
                          CancellationToken.None,
                          new FileDataStore(folder)).Result;
  </code></pre>
  
  <p>And use another way to create credentials</p>
  
  <pre><code>            using (var stream = new FileStream(Utility.AppPath + "/client_secrets.json", FileMode.Open, FileAccess.Read))
          {
              credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                  GoogleClientSecrets.Load(stream).Secrets,
                  scopes,
                  "user", CancellationToken.None, new FileDataStore(folder));
          }
  </code></pre>
  
  <p>But in both cases i am getting access denied.</p>
  
  <p>My assumption is that, it's happening because i am trying to use sample
  "Installed Applications"</p>
  
  <p>Please advice me what is the best way to do that in .net simple web application.</p>
  
  <p>Also share some code if any one done it successfully.</p>
  
  <p>Thanks in advance..!!!</p>