<commit_before>package org.broadinstitute.dsde.agora.server

import java.io.File
import java.util.Collections

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport
import com.google.api.client.json.jackson2.JacksonFactory
import com.google.api.services.storage.StorageScopes.DEVSTORAGE_FULL_CONTROL

object GoogleCredentialHandler {

  val one_minute = 60

  val credential: GoogleCredential = {
    val emailAddress = AgoraConfig.gcsServiceAccountUserEmail
    val JSON_FACTORY = JacksonFactory.getDefaultInstance
    val httpTransport = GoogleNetHttpTransport.newTrustedTransport()
    new GoogleCredential.Builder()
      .setTransport(httpTransport)
      .setJsonFactory(JSON_FACTORY)
      .setServiceAccountId(emailAddress)
      .setServiceAccountPrivateKeyFromP12File(new File(AgoraConfig.gcServiceAccountP12KeyFile))
      .setServiceAccountScopes(Collections.singleton(DEVSTORAGE_FULL_CONTROL))
      .build()
  }

  def accessToken: String = {
    val expires = Option(credential.getExpiresInSeconds)

    expires match {
      case Some(duration) => if (duration < one_minute) credential.refreshToken()
      case None => credential.refreshToken()
    }
    credential.getAccessToken
  }
}<commit_msg>change one_minute val to a Duraction<commit_after>package org.broadinstitute.dsde.agora.server

import java.io.File
import java.util.Collections

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport
import com.google.api.client.json.jackson2.JacksonFactory
import com.google.api.services.storage.StorageScopes.DEVSTORAGE_FULL_CONTROL
import scala.concurrent.duration._

object GoogleCredentialHandler {

  val credential: GoogleCredential = {
    val emailAddress = AgoraConfig.gcsServiceAccountUserEmail
    val JSON_FACTORY = JacksonFactory.getDefaultInstance
    val httpTransport = GoogleNetHttpTransport.newTrustedTransport()
    new GoogleCredential.Builder()
      .setTransport(httpTransport)
      .setJsonFactory(JSON_FACTORY)
      .setServiceAccountId(emailAddress)
      .setServiceAccountPrivateKeyFromP12File(new File(AgoraConfig.gcServiceAccountP12KeyFile))
      .setServiceAccountScopes(Collections.singleton(DEVSTORAGE_FULL_CONTROL))
      .build()
  }

  def accessToken: String = {
    val expires = Option(credential.getExpiresInSeconds)

    expires match {
      case Some(time) => if (Duration(time, SECONDS) < 1.minute) credential.refreshToken()
      case None => credential.refreshToken()
    }
    credential.getAccessToken
  }
}
{'fraction_non_alphanumeric': 0.08087679516250945, 'fraction_numerical': 0.005668934240362812, 'mean_word_length': 4.908482142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1698119', 'n_tokens_mistral': 789, 'n_tokens_neox': 767, 'n_words': 121}