Need help for migrating authentication to OAuth2.0 in google analytics

I am currently using Google management API for analytics v2.4, but the way i do the authentication is deprecated (function setUserCredentials), so I need to migrate to OAuth2.0 authentication, but I am having some problems to understand google documentation, about it.

        DataQuery query = new DataQuery(new URL(DATA_URL));
        query.setIds(tableId);
        query.setStartDate(startDate);
        query.setEndDate(endDate);
        query.setDimensions(dimensions);
        query.setMetrics(metrics);
        query.setMaxResults(10000);
        query.setStringCustomParameter("key", "API_key");

        return query;
    }

    private static DataFeed getDataFeed(String username, String password, String startDate, String endDate, String dimensions, String metrics) throws ServiceException, IOException {

        AnalyticsService myService = new AnalyticsService("xxxxxx");

        myService.setUserCredentials(username, password);

        DataQuery query = getQuery(GA_ID, startDate, endDate, dimensions, metrics, 1);
        DataFeed data = null;
        try{
            data = myService.getFeed(query, DataFeed.class);
        }catch(Exception e){
            e.printStackTrace();
        }

        return data;
    }

Can I still use the v2.4 and do the authentication with OAuth2.0 ?