<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fetch_friends(self, user):
 """ fetches the friends from g+ using the information on django-social-auth models user is an instance of UserSocialAuth. Notice that g+ contact api should be enabled in google cloud console and social auth scope has been set this way in settings.py GOOGLE_OAUTH_EXTRA_SCOPE = ['https://www.google.com/m8/feeds/'] Returns: collection of friend data dicts fetched from google contact api """


        if USING_ALLAUTH:
            social_app = SocialApp.objects.get_current('google')
            oauth_token = SocialToken.objects.get(account=user, app=social_app).token
        else:
            social_auth_backend = GoogleOAuth2Backend()
            # Get the access_token
            tokens = social_auth_backend.tokens(user)
            oauth_token = tokens['access_token']

        credentials = gdata.gauth.OAuth2Token(
            client_id=settings.GOOGLE_OAUTH2_CLIENT_ID,
            client_secret=settings.GOOGLE_OAUTH2_CLIENT_SECRET,
            scope='https://www.google.com/m8/feeds/',
            user_agent='gdata',
            access_token=oauth_token
        )
        client = gdata.contacts.client.ContactsClient()
        credentials.authorize(client)
        contacts = client.get_contacts()
        data = feedparser.parse(contacts.to_string())['entries']

        return data