fajar ainul fajar ainul - 1 year ago 185
Javascript Question

Google OAuth2 Origin Mismatch

I want to use Google Youtube Analytics API. I know that we have to use Oauth2, so I get my client ID and then follow this instruction https://developers.google.com/youtube/analytics/v1/sample-application cause I use youtube analytics for my web app.

I get confused when my request get error response

Error: origin_mismatch
enter image description here

enter image description here

I have checked my Authorized JavaScript origins, make sure that they are same. I also host my code.

just in case you wonder my code, here my index.php file


<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="index.js"></script>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript" src="https://apis.google.com/js/client.js?onload=onJSClientLoad"></script>


<div id="login-container" class="pre-auth">This application requires access to your YouTube account.
Please <a href="#" id="login-link">authorize</a> to continue.
<div class="post-auth">
<div id="message"></div>
<div id="chart"></div>
<div>Choose a Video:</div>
<ul id="video-list"></ul>


Did I do something wrong???
thanks in advance!

Answer Source

I have found my solution myself. I just change immediate: true to immediate: false on checkAuth function. I dont know why, but it works.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download