'Helper method to get the oauth token'

def get_auth_token(self, app_grant, app_client):

    token_data = {'grant_type': 'authorization_code', 'code': app_grant.code, 'client_id': app_client.client_id, 'client_secret': app_client.client_secret}
    token_resp = self.client.post('/oauth2/access_token/', data=token_data)
    self.assertEqual(token_resp.status_code, status.HTTP_200_OK)
    token_resp_json = json.loads(token_resp.content)
    return '{token_type}    {token}'.format(token_type=token_resp_json['token_type'], token=token_resp_json['access_token'])
