5.8K members online now
Understand information in your reports and troubleshoot reporting issues such as self-referrals, (not set) data, and inaccurate information
Guide Me

Can you use Reporting API V4 on HTTP website?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi there,

I have the following code, taken from the example for the Reporting API (V4), however, when I try validating the data I get the following error:


400. That’s an error.


Error: origin_mismatch


Which I can only assume is because my website is on HTTP not HTTPS. However, I cannot move the site to HTTPS. So is there any way to get this to work?


The code for the website is:


<!DOCTYPE html>
  <meta charset="utf-8">
  <title>Hello Analytics Reporting API V4</title>

<button id="auth-button" hidden>Authorize</button>

<h1>Hello Analytics Reporting API V4</h1>

<textarea cols="80" rows="20" id="query-output"></textarea>


  // Replace with your client ID from the developer console.
  var CLIENT_ID = 'MY ID';

  // Replace with your view ID.
  var VIEW_ID = 'MY ID';

  // Set the discovery URL.
  var DISCOVERY = '$discovery/rest';

  // Set authorized scope.
  var SCOPES = [''];

  function authorize(event) {
    // Handles the authorization flow.
    // `immediate` should be false when invoked from the button click.
    var useImmdiate = event ? false : true;
    var authData = {
      client_id: CLIENT_ID,
      scope: SCOPES,
      immediate: useImmdiate

    gapi.auth.authorize(authData, function(response) {
      var authButton = document.getElementById('auth-button');
      if (response.error) {
        authButton.hidden = false;
      else {
        authButton.hidden = true;

  function queryReports() {
    // Load the API from the client discovery URL.
    ).then(function() {

        // Call the Analytics Reporting API V4 batchGet method.
        gapi.client.analyticsreporting.reports.batchGet( {
        } ).then(function(response) {
          var formattedJson = JSON.stringify(response.result, null, 2);
          document.getElementById('query-output').value = formattedJson;
        .then(null, function(err) {
            // Log any errors.

  // Add an event listener to the 'auth-button'.
  document.getElementById('auth-button').addEventListener('click', authorize);

<script src=""></script>



1 Expert replyverified_user

Re: Can you use Reporting API V4 on HTTP website?

Top Contributor
# 2
Top Contributor
Make sure you defined a return URL from your cloud console that uses http, not https?
VP & Chief Evangelist at Hub'Scan | Contact me
Level 80 Digital Analytics Warrior, KPI Therapist and Keeper of the One True Tagging Plan

Re: Can you use Reporting API V4 on HTTP website?

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
When I set all the https to http I get the following

400. That’s an error.

Error: invalid_scope

Some requested scopes were invalid. {invalid=[]}

Learn more