             FOREIGN KEY (CONSUMER_KEY) REFERENCES IDN_OAUTH_CONSUMER_APPS(CONSUMER_KEY) ON DELETE CASCADE
 )ENGINE INNODB;
 
+CREATE TABLE IDN_OAUTH2_ACCESS_TOKEN (
+            TOKEN_ID VARCHAR (255),
+            ACCESS_TOKEN VARCHAR(255),
+            REFRESH_TOKEN VARCHAR(255),
+            CONSUMER_KEY VARCHAR(255),
+            AUTHZ_USER VARCHAR(100),
+            USER_TYPE VARCHAR (25),
+            TIME_CREATED TIMESTAMP DEFAULT 0,
+            REFRESH_TOKEN_TIME_CREATED TIMESTAMP DEFAULT 0,
+            VALIDITY_PERIOD BIGINT,
+            REFRESH_TOKEN_VALIDITY_PERIOD BIGINT,
+            TOKEN_SCOPE_HASH VARCHAR(32),
+            TOKEN_STATE VARCHAR(25) DEFAULT 'ACTIVE',
+            TOKEN_STATE_ID VARCHAR (128) DEFAULT 'NONE',
+            PRIMARY KEY (TOKEN_ID),
+            FOREIGN KEY (CONSUMER_KEY) REFERENCES IDN_OAUTH_CONSUMER_APPS(CONSUMER_KEY) ON DELETE CASCADE,
+            CONSTRAINT CON_APP_KEY UNIQUE (CONSUMER_KEY,AUTHZ_USER,USER_TYPE,TOKEN_SCOPE_HASH,TOKEN_STATE,TOKEN_STATE_ID)
+)ENGINE INNODB;
+
 CREATE TABLE IDN_OAUTH2_AUTHORIZATION_CODE (
-            AUTHORIZATION_CODE VARCHAR(255),
+            AUTHORIZATION_CODE VARCHAR(512),
             CONSUMER_KEY VARCHAR(255),
-	        CALLBACK_URL VARCHAR(1024),
-            SCOPE VARCHAR(767),
+	          CALLBACK_URL VARCHAR(1024),
+            SCOPE VARCHAR(2048),
             AUTHZ_USER VARCHAR(512),
-	        TIME_CREATED TIMESTAMP,
-	        VALIDITY_PERIOD BIGINT,
+            TIME_CREATED TIMESTAMP,
+            VALIDITY_PERIOD BIGINT,
+            STATE VARCHAR (25) DEFAULT 'ACTIVE',
+            TOKEN_ID VARCHAR(255),
             PRIMARY KEY (AUTHORIZATION_CODE),
             FOREIGN KEY (CONSUMER_KEY) REFERENCES IDN_OAUTH_CONSUMER_APPS(CONSUMER_KEY) ON DELETE CASCADE
 )ENGINE INNODB;
 
-CREATE TABLE IDN_OAUTH2_ACCESS_TOKEN (
-			ACCESS_TOKEN VARCHAR(255),
-			REFRESH_TOKEN VARCHAR(255),
-			CONSUMER_KEY VARCHAR(255),
-			AUTHZ_USER VARCHAR(100),
-			USER_TYPE VARCHAR (25),
-			TIME_CREATED TIMESTAMP DEFAULT 0,
-			VALIDITY_PERIOD BIGINT,
-			TOKEN_SCOPE VARCHAR(767),
-			TOKEN_STATE VARCHAR(25) DEFAULT 'ACTIVE',
-			TOKEN_STATE_ID VARCHAR (255) DEFAULT 'NONE',
-			PRIMARY KEY (ACCESS_TOKEN),
-            FOREIGN KEY (CONSUMER_KEY) REFERENCES IDN_OAUTH_CONSUMER_APPS(CONSUMER_KEY) ON DELETE CASCADE,
-            CONSTRAINT CON_APP_KEY UNIQUE (CONSUMER_KEY, AUTHZ_USER,USER_TYPE,TOKEN_STATE,TOKEN_STATE_ID,TOKEN_SCOPE)
-)ENGINE INNODB;
-
-CREATE INDEX IDX_OAUTH_ACCTKN_CONK_UTYPE ON IDN_OAUTH2_ACCESS_TOKEN ( CONSUMER_KEY,USER_TYPE,TOKEN_STATE);
+CREATE INDEX IDX_AT_CK_AU ON IDN_OAUTH2_ACCESS_TOKEN(CONSUMER_KEY, AUTHZ_USER, TOKEN_STATE, USER_TYPE);
+
+CREATE TABLE IDN_OAUTH2_SCOPE_ASSOCIATION (
+            TOKEN_ID VARCHAR (255),
+            TOKEN_SCOPE VARCHAR (60),
+            PRIMARY KEY (TOKEN_ID, TOKEN_SCOPE),
+            FOREIGN KEY (TOKEN_ID) REFERENCES IDN_OAUTH2_ACCESS_TOKEN(TOKEN_ID) ON DELETE CASCADE
+)ENGINE INNODB;
 
 CREATE TABLE IF NOT EXISTS IDN_OAUTH2_SCOPE (
             SCOPE_ID INT(11) NOT NULL AUTO_INCREMENT,

            RESOURCE_PATH VARCHAR(255) NOT NULL,
            SCOPE_ID INTEGER (11) NOT NULL,
            PRIMARY KEY (RESOURCE_PATH),
            FOREIGN KEY (SCOPE_ID) REFERENCES IDN_OAUTH2_SCOPE (SCOPE_ID) ON DELETE CASCADE ON UPDATE CASCADE
)ENGINE INNODB;

CREATE TABLE IDN_SCIM_GROUP (

-- Start of IDN Tables --
CREATE TABLE IDN_BASE_TABLE (
            PRODUCT_NAME VARCHAR(20),
            PRIMARY KEY (PRODUCT_NAME)
