Skip to content
This repository has been archived by the owner on Apr 20, 2022. It is now read-only.

Two Factor Authentication

johnnycoinbase edited this page Jan 10, 2019 · 1 revision

When performing send money request with coinbase.transactionResource.send(), there is an optional twoFactorAuthToken parameter. To perform this request, you have to send it twice:

  • First time with optional twoFactorAuthToken: nil

    let sendParameters = SendTransactionParameters(to: "[email protected]",
                                                amount: "0.01",
                                                currency: "BTC",
                                                description: "Thanks for the coffee!")
                
    // Completion will recive `Result.failure`
    coinbase.transactionResource.send(accountID: <account_id>,
                                      twoFactorAuthToken: nil,
                                      parameters: sendParameters, 
                                      completion: completion)
  • Request will fail with an error:

    NetworkError.responseError(errorResponse, _)

    where errorResponse.errors contains an error with id equal to ClientErrorID.twoFactorRequired.

    The user should get the code via a selected channel (e.g. SMS) and then you can prompt the user to input the code.

  • Repeat the request with the auth token and same request parameters:

    coinbase.transactionResource.send(accountID: <account_id>,
                                      twoFactorAuthToken: <2fa_token>,
                                      parameters: sendParameters, 
                                      completion: completion)
Clone this wiki locally