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
I have checked my Authorized JavaScript origins, make sure that they are same. I also host my code.
EDIT
just in case you wonder my code, here my index.php file
<html>
<head>
<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>
</head>
</body>
<div id="login-container" class="pre-auth">This application requires access to your YouTube account.
Please authorize to continue.
</div>
<div class="post-auth">
<div id="message"></div>
<div id="chart"></div>
<div>Choose a Video:</div>
<ul id="video-list"></ul>
</div>
<body>
`
Did I do something wrong???
thanks in advance!
Make sure that the OAuth ClientId you're using matches with the URI Origin you've specified in your Google Dev Console. For example you have this Client ID 1234567890 for the URI origin http://www.mysimplesite.com in GDC, that ClientID will only work on that domain.
If you want that Client ID to work on http://www.myawesomesite.com as well, you'd have to add it on the list of URIs. If you use it in a domain not specified in "Authorised Javascript origins", you will have origin mismatch error.
Note: Make sure you've enabled Youtube API as well.
For additional reference you may check this SO thread as well.
I have found my solution myself. I just change immediate: true to immediate: false on checkAuth function. I dont know why, but it works.
Related
I need to make a recaptcha V2 harvester in Electron JS. I tried the following code but all I get it "ERROR for site owner: Invalid domain for site key". I think I need to intercept requests. Someone suggested me to use "interceptBufferProtocol" method in JS but I don't know how to use that. Can someone help me ?
<html>
<head>
<title>Captcha Harvester</title>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</head>
<body>
<form action="/submit" method="POST">
<div class="g-recaptcha" id="captchaFrame" data-sitekey="actual-site-key" data-callback="sub"></div>
</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</body>
</html>
This error is due to "Domain mismatching".
Please set the domain of target site.
Generally, following method is used for harvesting captchas.
Open Webdriver.
Set the domain of target site.
Inject harvesting code
Just to make this clear, I am referring to this google sign as there are multiple: Google Sign-In for your web app
I have both the meta tag and script tag in the header of my page:
<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="[ThatsWhereMyIDIs].apps.googleusercontent.com">
as well as the div element for the Sign-In within my body:
<div class="g-signin2" data-onsuccess="onSignIn" onclick="console.log('yay');"></div>
I used the 'yay' to check if the element was triggered, and it is, however the "data-onsuccess" is never called.
What could be the reason for that and furthermore, how do I fix it?
Any help is appreciated.
I have the same problem but only when I deploy. It works in a local server. I think it is because it requires https and I do not have that for the server I am testing.
Recently I develop a web application which has worked very well, than I move this web application into 000webhost.com and my domain is ks-hospitaldemo.tk. Now my problem is after upload my web application into free server my all JavaScript and jQuery are not worked. I use the following code ::
<footer id="indexFooter">
</footer>
</div>
<script type="text/javascript" src="_javascript/jquery-1.9.1.js"></script>
<script type="text/javascript" src="_javascript/menuBar.js"></script>
All my JavaScript file is placed into _javasSript folder in server.
Then I check my code and find some code which is not done by me, probably hosting server. This code is given below::
<!--//--><script type="text/javascript" src="http://stats.hosting24.com/count.php">
</script> <!--//--><script language="javascript">
<!--bmi_SafeAddOnload(bmi_load,"bmi_orig_img",0);//-->
</script>
Please help me to find my problem.
The new web server is using case-sensitive file lookups. The exact name of the directory is _javaScript but it's referenced in the HTML as _javascript. Use the exact name to fix the problem:
<script type="text/javascript" src="_javaScript/jquery-1.9.1.js"></script>
<script type="text/javascript" src="_javaScript/menuBar.js"></script>
You may want to check the permissions on the _javascript folder. Also, 000 Webhost is known to have problems with Google Analytics. If you have a Google Analytics code on your site, try disabling it.
Some proxy / CDN services / providers inject or transform code in your .html pages to "speed up" data transfer. I had the same problem when accessing my website from a smartphone.
The solution that worked for me was to append Cache-control in the head of the page:
<meta http-equiv="Cache-control" content="no-transform"/>
I'm following this Site which is a easy way to add a customised tweet box and button on my site and will help in update of post.
As per its functionality, once we write any messages in the textbox and click on tweet button we will get the twitter login pop up window, once we are authenticated our message will be posted on our twitter account wall.
But when i run this code, i'm getting the pop up window and once i provide my credentials the window closes but no message is posted in the twitter account. When i checked on my javascript console im getting error:
Unsafe JavaScript attempt to access frame with https://api.twitter.com/xd_receiver.html from frame with URL about:blank. The frame requesting access has a protocol of 'http', the frame being accessed has a protocol of 'https'. Protocols must match.
I dont know what this error means as my site through which im running the form is clorderdev2.uvacha.com
Below is my code :
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://platform.twitter.com/anywhere.js?id=YOURCONSUMERKEY&v=1"></script>
<script type="text/javascript" src="Scripts/jquery.jtweetsanywhere-1.3.1.min.js"></script>
<script type="text/javascript" src="Scripts/jtweetsanywhere-de-1.3.1.min.js"></script>
<div id="jTweetsAnywhereSample"></div>
<script type="text/javascript">
$('#jTweetsAnywhereSample').jTweetsAnywhere({
showTweetBox:{
counter: true,
width: 380,
height: 65,
label: '<span style="color: #A4A4A4">What\'s happening?</span>',
defaultContent: '#jTweetsAnywhere',
onTweet: function(textTweet, htmlTweet){
alert('You tweeted: ' + textTweet);
}
}
});</script>
There's a better plugin to get Twitter tweets, and it's called livetwitter.
All the information you need is here:
https://github.com/elektronaut/jquery.livetwitter
The problem is that a script, somewhere, is trying to communicate between http:// and https:// protocols. For security reasons, JavaScript can't do that. This is most likely a bug in one of the libraries you're using.
I'd suggest using the official twitter implementation, if that's a possible alternative.
I've created a button whose function is to hide itself when clicked. But, it isn't working.Here's the code :
<html>
<body>
<button id="b">HIDE</button>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#b").click(function(){
$("#b").hide();
});
});
</script>
</body>
</head>
What's wrong with it?
That should work, but I'd strongly suggest you research the HTML for a valid document, i.e. </head> must appear before <body>.
Along with what alex said, it's possible that Chrome is blocking your request to the CDN-hosted jQuery. You can either give that domain valid permissions in manifest.json or simply download the copy of jQuery and store it locally.
If you are using SSL for your site, then you should serve your javascript/js file via https, else chrome will block it and causing your site's feature that is using that script not working.
I noticed that you are using http to call jquery from google cdn. May be it is causing that problem.