Class: Onlyfans::Resources::Authenticate

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyfans/resources/authenticate.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Authenticate

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Authenticate.

Parameters:



157
158
159
# File 'lib/onlyfans/resources/authenticate.rb', line 157

def initialize(client:)
  @client = client
end

Instance Method Details

#poll_status(attempt_id, request_options: {}) ⇒ Onlyfans::Models::AuthenticatePollStatusResponse

Poll the status of the authentication process. Eg. if 2FA is required, we will ask you for the code using the ‘twoFactorPending = true` in the response body. For `mobile_app` auth, the response includes `mobile_auth_session_deeplink` while the session is pending.

Parameters:

  • attempt_id (String)

    The attempt ID of the authentication process

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



20
21
22
23
24
25
26
27
# File 'lib/onlyfans/resources/authenticate.rb', line 20

def poll_status(attempt_id, params = {})
  @client.request(
    method: :get,
    path: ["api/authenticate/%1$s", attempt_id],
    model: Onlyfans::Models::AuthenticatePollStatusResponse,
    options: params[:request_options]
  )
end

#reauthenticate(account_id, request_options: {}) ⇒ Onlyfans::Models::AuthenticateReauthenticateResponse

Trigger account reauthentication without the need to submit email & password again.

Parameters:

  • account_id (String)

    The Account ID of the authentication process

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



41
42
43
44
45
46
47
48
# File 'lib/onlyfans/resources/authenticate.rb', line 41

def reauthenticate(, params = {})
  @client.request(
    method: :post,
    path: ["api/authenticate/%1$s/reauthenticate", ],
    model: Onlyfans::Models::AuthenticateReauthenticateResponse,
    options: params[:request_options]
  )
end

#send_2fa_email(attempt_id, request_options: {}) ⇒ Onlyfans::Models::AuthenticateSend2faEmailResponse

Send 2FA verification e-mail to the creator’s email so they can verify login on their device without your input. The e-mail will be sent to the e-mail address used for signing into OnlyFans.

Parameters:

  • attempt_id (String)

    The attempt ID of the authentication process

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



63
64
65
66
67
68
69
70
# File 'lib/onlyfans/resources/authenticate.rb', line 63

def send_2fa_email(attempt_id, params = {})
  @client.request(
    method: :post,
    path: ["api/authenticate/%1$s/send-email-to-creator", attempt_id],
    model: Onlyfans::Models::AuthenticateSend2faEmailResponse,
    options: params[:request_options]
  )
end

#start(auth_id: nil, auth_type: nil, cookies: nil, custom_proxy: nil, email: nil, force_connect: nil, name: nil, password: nil, proxy_country: nil, user_agent: nil, xbc: nil, request_options: {}) ⇒ Onlyfans::Models::AuthenticateStartResponse::UnionMember0, Onlyfans::Models::AuthenticateStartResponse::UnionMember1

Some parameter documentations has been truncated, see Models::AuthenticateStartParams for more details.

Start the authentication process for a new account. Supports three methods: email/password (default), cookies & headers (raw_data), or FansAPI Auth+ mobile app (mobile_app). For email/password, our systems will bypass Captcha and ask you for 2FA if required. For raw_data, provide session cookies directly for instant authentication. For mobile_app, the response includes a ‘mobile_auth_session_deeplink` that the creator opens on their phone (or scans as a QR code) to complete authentication via the FansAPI Auth+ mobile app. All credentials are stored securely and encrypted at rest.

Parameters:

  • auth_id (String)

    The auth_id from OnlyFans session cookies. Required when auth_type is ‘raw_data`

  • auth_type (Symbol, Onlyfans::Models::AuthenticateStartParams::AuthType)

    The authentication method to use. Defaults to ‘email_password` if omitted. Use `

  • cookies (String)

    The full cookie string (semicolon-separated). Required when auth_type is ‘raw_da

  • custom_proxy (Onlyfans::Models::AuthenticateStartParams::CustomProxy)

    Custom proxy configuration. Cannot be used together with proxyCountry.

  • email (String)

    The email address of the OnlyFans account. Required when auth_type is ‘email_pas

  • force_connect (Boolean)

    Set to true to connect the account even if it already exists

  • name (String)

    A display name for the account. If omitted, defaults to the email address or aut

  • password (String)

    The password of the OnlyFans account. Required when auth_type is ‘email_password

  • proxy_country (Symbol, Onlyfans::Models::AuthenticateStartParams::ProxyCountry)

    The country of the managed proxy server you want to use. Eg. “us” for United Sta

  • user_agent (String)

    The browser User-Agent string. Required when auth_type is ‘raw_data`.

  • xbc (String)

    The X-BC token from request headers. Required when auth_type is ‘raw_data`.

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



113
114
115
116
117
118
119
120
121
122
# File 'lib/onlyfans/resources/authenticate.rb', line 113

def start(params = {})
  parsed, options = Onlyfans::AuthenticateStartParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/authenticate",
    body: parsed,
    model: Onlyfans::Models::AuthenticateStartResponse,
    options: options
  )
end

#submit_2fa(attempt_id, code: nil, selfie_verification_completed: nil, request_options: {}) ⇒ Onlyfans::Models::AuthenticateSubmit2faResponse

Some parameter documentations has been truncated, see Models::AuthenticateSubmit2faParams for more details.

Submit the 2FA code, or Selfie Verification status, for the authentication process.

Parameters:

  • attempt_id (String)

    The attempt ID of the authentication process

  • code (String)

    The 2FA code you received on your phone. Must be empty if ‘selfie_verification_c

  • selfie_verification_completed (Object)

    This field is required when code is not present.

  • request_options (Onlyfans::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



143
144
145
146
147
148
149
150
151
152
# File 'lib/onlyfans/resources/authenticate.rb', line 143

def submit_2fa(attempt_id, params = {})
  parsed, options = Onlyfans::AuthenticateSubmit2faParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["api/authenticate/%1$s", attempt_id],
    body: parsed,
    model: Onlyfans::Models::AuthenticateSubmit2faResponse,
    options: options
  )
end