/**
 * @license
 * Copyright 2015 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 */

CLASS({
  name: 'GoogleDriveDAOFactory',
  package: 'foam.apps.builder.dao',

  extendsModel: 'foam.apps.builder.dao.DAOFactory',

  requires: [
    'com.google.drive.FileDAO',
    'foam.dao.EasyDAO',
  ],

  properties: [
    {
      name: 'name',
    },
    {
      name: 'label',
    },
    {
      model_: 'FactoryProperty',
      hidden: true,
      name: 'factory', //TODO(jacksonic): Should be named .create, but can't until Model.create is moved
      defaultValue: function() {
        return this.EasyDAO.create({
          model: this.X.lookup(this.modelType),
          name: this.name,
          daoType: this.FileDAO,
          cache: true,
          guid: true,
          logging: true
        });
      },
    }
  ],

});

@@ -500,21 +500,61 @@
 syDAO',%0A
+    'foam.oauth2.AutoOAuth2',%0A    'XHR'%0A
   %5D,%0A
-
 %0A  prope
@@ -631,24 +631,108 @@
    %7D,%0A    %7B%0A
+      name: 'authClientId'%0A    %7D,%0A    %7B%0A      name: 'authClientSecret'%0A    %7D,%0A    %7B%0A
       model_
@@ -910,16 +910,436 @@
 ion() %7B%0A
+%0A        var authX = this.AutoOAuth2.create().Y;%0A        var agent = authX.lookup('foam.oauth2.EasyOAuth2').create(%7B%0A          scopes: %5B%0A            'https://www.googleapis.com/auth/drive.appfolder'%0A          %5D,%0A          clientId: this.authClientId,%0A          clientSecret: this.authClientSecret%0A        %7D);%0A%0A        authX.registerModel(%0A          this.XHR.xbind(%7B%0A            authAgent: agent%0A          %7D)%0A        );%0A%0A
         
@@ -1544,16 +1544,16 @@
 g: true%0A
-
         
@@ -1553,16 +1553,23 @@
        %7D
+, authX
 );%0A     

Add auth client id and auth secret to GoogleDriveDAOFactory. Update GoogleDriveDAOFactory to create and register auth agent.