# getAuthCode

> The Alipay+ client SDK uses the getAuthCode API to obtain the authorization code from the MPP.

The Alipay+ client SDK uses the **getAuthCode** API to obtain the authorization code from the Mobile Payment Provider (MPP).

## Method signature

```java
public interface CommonOAuthService {

    void getAuthCode(CommonOAuthServiceParams params, Callback<CommonOAuthServiceResult> callback);

}
```

## Request parameters

| **Item** | **Type** | **Description** | **Required** |
| --- | --- | --- | --- |
| params | [CommonOAuthServiceParams](android_appendix#zrgJx) | Parameters that are required to obtain the authorization code. | M |
| callback | Callback | The callback to be invoked after the process to obtain the authorization code ends. See [Callback](#jd8MZ) for details. | M |

#### Callback

| **Item** | **Type** | **Description** | **Required** |
| --- | --- | --- | --- |
| result | [CommonOAuthServiceResult](android_appendix#jFKzK) | The result information that is required if the authorization is successful. | O |
| errorCode | String | The error code that is required if the authorization fails. | O |
| errorMessage | String | The error message that is required if the request fails. | O |

## Response parameters

N/A

## Sample

Definition of _YOUR\_OAUTH\_SERVICE\_CLASS_:

```java
public class YOUR_OAUTH_SERVICE_CLASS implements CommonOAuthService {

    public void getAuthCode(CommonOAuthServiceParams params, Callback<CommonOAuthServiceResult>) {

        //Your logic

        //On success
        CommonOAuthServiceResult result = new CommonOAuthServiceResult();
        result.authCode = "XXX";
        List<String> authSuccessScopes = new ArrayList();
        authSuccessScopes.add("auth_base");
        result.authSuccessScopes = authSuccessScopes;
        result.authErrorScopes = new HashMap();
        callback.onSuccess(result);

        //On failure
        callback.onFailure(1001, "XXXX");


    }

}
```

Instance of _YOUR\_OAUTH\_SERVICE\_CLASS_:

```java
AlipayPlusClient.getInstance().commonOAuthService = new YOUR_OAUTH_SERVICE_CLASS();
```