<commit_before>import {OAuth2Strategy as Strategy} from 'passport-google-oauth'

// ===================================================================

export const configurationSchema = {
  type: 'object',
  properties: {
    callbackURL: {
      type: 'string',
      description: 'Must be exactly the same as specified on the Google developer console.'
    },
    clientID: {
      type: 'string'
    },
    clientSecret: {
      type: 'string'
    }
  },
  required: ['callbackURL', 'clientID', 'clientSecret']
}

// ===================================================================

class AuthGoogleXoPlugin {
  constructor ({ xo }) {
    this._conf = null
    this._xo = xo
  }

  configure (conf) {
    this._conf = {
      ...conf,
      scope: 'https://www.googleapis.com/auth/plus.login'
    }
  }

  load () {
    const {_xo: xo} = this

    xo.registerPassportStrategy(new Strategy(this._conf, async (accessToken, refreshToken, profile, done) => {
      try {
        console.log(profile)
        done(null, await xo.registerUser('google', profile.displayName))
      } catch (error) {
        done(error.message)
      }
    }))
  }
}

// ===================================================================

export default ({xo}) => new AuthGoogleXoPlugin(xo)
<commit_msg>chore: factory function pass options directly<commit_after>import {OAuth2Strategy as Strategy} from 'passport-google-oauth'

// ===================================================================

export const configurationSchema = {
  type: 'object',
  properties: {
    callbackURL: {
      type: 'string',
      description: 'Must be exactly the same as specified on the Google developer console.'
    },
    clientID: {
      type: 'string'
    },
    clientSecret: {
      type: 'string'
    }
  },
  required: ['callbackURL', 'clientID', 'clientSecret']
}

// ===================================================================

class AuthGoogleXoPlugin {
  constructor ({ xo }) {
    this._conf = null
    this._xo = xo
  }

  configure (conf) {
    this._conf = {
      ...conf,
      scope: 'https://www.googleapis.com/auth/plus.login'
    }
  }

  load () {
    const xo = this._xo

    xo.registerPassportStrategy(new Strategy(this._conf, async (accessToken, refreshToken, profile, done) => {
      try {
        console.log(profile)
        done(null, await xo.registerUser('google', profile.displayName))
      } catch (error) {
        done(error.message)
      }
    }))
  }
}

// ===================================================================

export default opts => new AuthGoogleXoPlugin(opts)

{'fraction_non_alphanumeric': 0.26833013435700576, 'fraction_numerical': 0.0007677543186180423, 'mean_word_length': 3.203225806451613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '5553123', 'n_tokens_mistral': 753, 'n_tokens_neox': 714, 'n_words': 160}