- [HTTP request](https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/refreshToken#body.HTTP_TEMPLATE)
- [Request body](https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/refreshToken#body.request_body)
  - [JSON representation](https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/refreshToken#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/refreshToken#body.response_body)
- [RefreshTokenResponse](https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/refreshToken#RefreshTokenResponse)
  - [JSON representation](https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/refreshToken#RefreshTokenResponse.SCHEMA_REPRESENTATION)
- [RefreshTokenResultCode](https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/refreshToken#RefreshTokenResultCode)

Refreshes a payment token's expiration date.

Token refresh happens when a token has expired, is near expiry, or when Google chooses to refresh based on risk profiles. The user is reauthenticated prior to calling this method. The `authenticationRequestId` that is passed contains the proof of authentication. The `googlePaymentToken` (GPT) is passed as well. A successful response to this call extends the GPT's expiry date.

If Google sends a GPT that the integrator has never associated before, then it throws an error.

If the endpoint encounters an error while processing the request, the response body from this endpoint should be of type `https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/ErrorResponse`.

An example request looks like:


    {
      "requestHeader": {
        "protocolVersion": {
          "major": 1,
          "minor": 0,
          "revision": 0
        },
        "requestId": "bhHmmdHHvbeY",
        "requestTimestamp": "1481899949606"
      },
      "authenticationRequestId": "dGVzdHRva2VuZnJvbWdvb2dsZQ==",
      "googlePaymentToken": "ZXhhbXBsZSB1bmlxdWUgcGF5bWVudCB0b2tlbiB2YWx1ZQ"
    }

An example response looks like:


    {
      "responseHeader": {
        "responseTimestamp": "1481900013178"
      },
      "paymentIntegratorRefreshTokenId": "iuKndnVzaCB0b2tlbiYYke=",
      "tokenExpirationTime": "1481901824177",
      "result": "SUCCESS"
    }

### HTTP request

`POST https://www.integratorhost.example.com/integrator-base-path/e-wallets-v1/refreshToken`

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "requestHeader": { object (`https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/RequestHeader`) }, "googlePaymentToken": string, // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "authenticationRequestId": string, "otpVerification": { object (`https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/OtpVerification`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `requestHeader` | ``object (`https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/RequestHeader`)`` **REQUIRED**: Common header for all requests. |
| `googlePaymentToken` | `string` **REQUIRED** : This is the token to be refreshed. This will not be a new token, but an existing token that has already been established via associateAccount. If the token is unknown a status of `FAILED_PRECONDITION` should be returned. |
| **REQUIRED**: The type of account verification used for this transaction. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `authenticationRequestId` | `string` The `requestId` of the authentication request that preceded this call. This is only present if the user went through the Android app or web authentication paths. |
| `otpVerification` | ``object (`https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/OtpVerification`)`` Data necessary to verify an OTP generated from `sendOtp`. This is only present if the user went through the `sendOtp` path. |
| End of mutually exclusive fields. ||

### Response body

This method supports multiple return types. For additional information about what 4XX or 5XX HTTP status code to return with an `ErrorResponse`, consult the `ErrorResponse` object and [HTTP status codes documentation](https://developers.google.com/pay/e-wallets-v1/guides/connectivity/protocol-standards#http_status_codes).

| Possible response messages ||
|---|---|
| HTTP 200 Status | ``object (`https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/refreshToken#RefreshTokenResponse`)`` |
| HTTP 4XX / 5XX Status | ``object (`https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/ErrorResponse`)`` |
| End of mutually exclusive fields. ||

## RefreshTokenResponse

Response object for the refresh token method.

| JSON representation |
|---|
| ``` { "responseHeader": { object (`https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/ResponseHeader`) }, "paymentIntegratorRefreshTokenId": string, "tokenExpirationTime": string, "userMessage": string, "result": enum (`https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/refreshToken#RefreshTokenResultCode`) } ``` |

| Fields ||
|---|---|
| `responseHeader` | ``object (`https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/ResponseHeader`)`` **REQUIRED**: Common header for all responses. |
| `paymentIntegratorRefreshTokenId` | `string` **OPTIONAL**: This identifier is specific to the integrator and is generated by the integrator. It is used for debugging purposes only in order to identify this call. This is the identifier that the integrator knows this call by. |
| `tokenExpirationTime` | `string (https://developers.google.com/discovery/v1/type-format format)` **OPTIONAL** : Milliseconds since epoch when the token expires. Use `0` to signal the token does not expire. |
| `userMessage (deprecated)` | `string` > [!WARNING] > This was never implemented and is being removed in future versions. This field is ignored. **DEPRECATED** : A description of the result to be displayed to the user if the result is not `SUCCESS`. |
| `result` | ``enum (`https://developers.google.com/pay/e-wallets-v1/payment-integrator-e-wallets-api/refreshToken#RefreshTokenResultCode`)`` **REQUIRED**: Result of this call. |

## RefreshTokenResultCode

Result codes for refresh token.

| Enums ||
|---|---|
| `UNKNOWN_RESULT` | Do not ever set this default value! |
| `SUCCESS` | Successful association. |
| `USER_AUTHENTICATION_FAILED` | Even though the account authentication bundle was returned, the user authentication failed. |
| `OTP_NOT_MATCHED` | OTP did not match what the integrator sent. |
| `OTP_ALREADY_USED` | OTP was already used. |
| `ACCOUNT_CLOSED` | The user's account held with the integrator has been closed. Returning this value will cause the user's instrument to be closed with Google. The user will be forced to add a new instrument by going through the association flow again. |
| `ACCOUNT_CLOSED_ACCOUNT_TAKEN_OVER` | The user's account with the integrator has been closed, suspected account take over. Returning this value will cause the user's instrument to be closed with Google. The user will be forced to add a new instrument by going through the association flow again. |
| `ACCOUNT_CLOSED_FRAUD` | The user's account held with the integrator has been closed because of fraud. Returning this value will cause the user's instrument to be closed with Google. The user will be forced to add a new instrument by going through the association flow again. |