def obtain_access_token(self):
        """Returns an OAuth 2 access token to make OAuth 2 authenticated read-only calls.

        :rtype: string
        """
        if self.oauth_version != 2:
            raise TwythonError('This method can only be called when your OAuth version is 2.0.')

        data = {'grant_type': 'client_credentials'}
        basic_auth = HTTPBasicAuth(self.app_key, self.app_secret)
        try:
            response = self.client.post(self.request_token_url,
                                        data=data, auth=basic_auth)
            content = response.content.decode('utf-8')
            try:
                content = content.json()
            except __HOLE__:
                content = json.loads(content)
                access_token = content['access_token']
        except (ValueError, requests.exceptions.RequestException):
            raise TwythonAuthError('Unable to obtain OAuth 2 access token.')
        else:
            return access_token
dataset/ETHPy150Open splunk/splunk-app-twitter/twitter2/bin/twython/api.py/Twython.obtain_access_token