class Faker::Omniauth

def google(name: nil, email: nil, uid: Number.number(digits: 9).to_s)

Returns:
  • (Hash) - An auth hash in the format provided by omniauth-google.

Parameters:
  • uid (String) -- A specific UID to return in the response.
  • email (String) -- A specific email to return in the response.
  • name (String) -- A specific name to return in the response.
def google(name: nil, email: nil, uid: Number.number(digits: 9).to_s)
  auth = Omniauth.new(name: name, email: email)
  {
    provider: 'google_oauth2',
    uid: uid,
    info: {
      name: auth.name,
      first_name: auth.first_name,
      last_name: auth.last_name,
      email: auth.email,
      image: image
    },
    credentials: {
      token: Crypto.md5,
      refresh_token: Crypto.md5,
      expires_at: Time.forward.to_i,
      expires: true
    },
    extra: {
      raw_info: {
        sub: uid,
        email: auth.email,
        email_verified: random_boolean.to_s,
        name: auth.name,
        given_name: auth.first_name,
        family_name: auth.last_name,
        profile: "https://plus.google.com/#{uid}",
        picture: image,
        gender: gender,
        birthday: Date.backward(days: 36_400).strftime('%Y-%m-%d'),
        locale: 'en',
        hd: "#{Company.name.downcase}.com"
      },
      id_info: {
        iss: 'accounts.google.com',
        at_hash: Crypto.md5,
        email_verified: true,
        sub: Number.number(digits: 28).to_s,
        azp: 'APP_ID',
        email: auth.email,
        aud: 'APP_ID',
        iat: Time.forward.to_i,
        exp: Time.forward.to_i,
        openid_id: "https://www.google.com/accounts/o8/id?id=#{uid}"
      }
    }
  }
end