title: Google Analytics API Python Error 403 - Insufficient Permissions
body: <p>I've set my analytics api and credentials, downloaded the client_secrets.json and copied the client_email.</p>
  <p>Then, I went to my Google Analytics account &gt; property &gt; view &gt; admin &gt; User Management and added that email as a new user with read permissions.
  This went just fine, no error or whatsoever.</p>
  <p>Now, when I try to make use of the api via python, i get this error:</p>
  <pre><code>googleapiclient.errors.HttpError: &lt;HttpError 403 when requesting https://analyticsreporting.googleapis.com/v4/reports:batchGet?alt=json returned &quot;User does not have sufficient permissions for this profile.&quot;. Details: &quot;User does not have sufficient permissions for this profile.&quot;&gt;
  </code></pre>
  <p>I'm going crazy with this. Don't know what's going on and how to fix it.</p>
  <p>Code:</p>
  <pre><code>from googleapiclient.discovery import build
  from oauth2client.service_account import ServiceAccountCredentials
  
  
  SCOPES = ['https://www.googleapis.com/auth/analytics.readonly']
  KEY_FILE_LOCATION = 'client_secrets.json'
  VIEW_ID = 'view_id' #exampe '12341234'
  
  
  def initialize_analyticsreporting():
      credentials = ServiceAccountCredentials.from_json_keyfile_name(
          KEY_FILE_LOCATION, SCOPES)
      analytics = build('analyticsreporting', 'v4', credentials=credentials)
      return analytics
  
  
  def get_report(analytics):
      return analytics.reports().batchGet(
          body={
              'reportRequests': [
                  {
                      'viewId': VIEW_ID,
                      'dateRanges': [{'startDate': '7daysAgo', 'endDate': 'today'}],
                      'metrics': [{'expression': 'ga:sessions'}],
                      'dimensions': [{'name': 'ga:country'}]
                  }]
          }
      ).execute()
  
  
  def print_response(response):
    &quot;&quot;&quot;Parses and prints the Analytics Reporting API V4 response.
  
    Args:
      response: An Analytics Reporting API V4 response.
    &quot;&quot;&quot;
    for report in response.get('reports', []):
      columnHeader = report.get('columnHeader', {})
      dimensionHeaders = columnHeader.get('dimensions', [])
      metricHeaders = columnHeader.get('metricHeader', {}).get('metricHeaderEntries', [])
  
      for row in report.get('data', {}).get('rows', []):
        dimensions = row.get('dimensions', [])
        dateRangeValues = row.get('metrics', [])
  
        for header, dimension in zip(dimensionHeaders, dimensions):
          print(header + ': ', dimension)
  
        for i, values in enumerate(dateRangeValues):
          print('Date range:', str(i))
          for metricHeader, value in zip(metricHeaders, values.get('values')):
            print(metricHeader.get('name') + ':', value)
  
  
  def main():
    analytics = initialize_analyticsreporting()
    response = get_report(analytics)
    print_response(response)
  
  if __name__ == '__main__':
    main()
  </code></pre>
  <p>Can someone help me please?
  Thanks!</p>