I am trying my mobile application login through google account.
I got this error invalid request and invalid parameter value for origin:missing authority:file://. How to resolve it can any one please help me.
I am trying to checking my application in android mobile i got this below error.
var CLIENT_ID = '349212001841-0o5cf26ah1g7fc4ufsfa1unk0ph3qoab.apps.googleusercontent.com';
var SCOPES = [ 'https://www.googleapis.com/auth/gmail.readonly' ];
function checkAuth() {
gapi.auth.authorize({
'client_id' : CLIENT_ID,
'scope' : SCOPES.join(' '),
'immediate' : true
}, handleAuthResult);
}
function handleAuthResult(authResult) {
alert("success")
var authorizeDiv = document.getElementById('authorize-button');
if (authResult && !authResult.error) {
authorizeDiv.style.display = 'none';
loadGmailApi();
} else {
authorizeDiv.style.display = 'inline';
}
}
function handleAuthClick(event) {
alert("failure")
gapi.auth.authorize({
client_id : CLIENT_ID,
scope : SCOPES,
immediate : false
}, handleAuthResult);
return false;
}
function loadGmailApi() {
gapi.client.load('gmail', 'v1', listLabels);
}
function listLabels() {
var request = gapi.client.gmail.users.labels.list({
'userId' : 'me'
});
request.execute(function(resp) {
var labels = resp.labels;
appendPre('Labels:');
if (labels && labels.length > 0) {
for (i = 0; i < labels.length; i++) {
var label = labels[i];
appendPre(label.name)
}
} else {
appendPre('No Labels found.');
}
});
}
function appendPre(message) {
var pre = document.getElementById('output');
var textContent = document.createTextNode(message + '\n');
pre.appendChild(textContent);
}
<div data-role="page" id="loginPage">
<div data-role="content" style="padding: 15px">
<h1 id="fb-welcome"></h1>
<label for="text">User Name:</label><input type="text" name="text" id="unL">
<label for="text">Password:</label><input type="password" name="text" id="pwdL">
LOGIN
via Facebook Login
via Google Login
</div>
</div>
<div data-role="page" id="dashboardPage">
<div data-role="header" id="header" data-position="fixed">
<h3>DashBord</h3>
</div>
<div data-role="content" style="padding: 15px">
<a href="#" data-role="button" onclick='Logout();'>LogOut</a>
</div>
</div>
Related
I am a child with an application with Ionic 4, my application is already logging in with Email, Facebook and Google using Firebase. I created a comments page and the comments are already being saved in Firestore and being displayed on a page. Wow do I get the logged in user data and insert it in this page. Comments?
I used the following solution:
JS:
in the builder
fireAuth.user.subscribe((data => {
this.user = data;
}));
Methods
listarComentarios() {
this.crudService.read_Comentarios().subscribe(data => {
this.comentarios = data.map(e => {
return {
id: e.payload.doc.id,
isEdit: false,
Comentario: e.payload.doc.data()['Comentario'],
Usuario: e.payload.doc.data()['Usuario'],
Foto: e.payload.doc.data()['Foto']
};
})
console.log(this.comentarios);
});
CreateRecord() {
let record = {};
record['Comentario'] = this.comentarioUsuario;
record['Usuario'] = this.user.displayName
record['Foto'] = this.user.photoURL
this.crudService.create_NewComentario(record).then(resp => {
this.comentarioUsuario = "";
this.user.displayName = "";
this.user.photoURL = "";
console.log(resp);
})
.catch(error => {
console.log(error);
});
HTML:
<ion-content>
<ion-grid *ngFor="let item of comentarios">
<span *ngIf="!item.isEdit; else elseBlock">
<!-- this rows will represent sample comments -->
<ion-row class="post-content">
<ion-col size="2" >
<ion-avatar class="ion-align-self-start">
<img class="icon-photo" [src]="item.Foto">
</ion-avatar>
</ion-col>
<ion-col size="6">
<div>
<p><strong>{{item.Usuario}} </strong>{{item.Comentario}}</p>
</div>
</ion-col>
<ion-col>
I am developing a application where I want to get values entered by user in webpage of android WebView. How we get the data entered in EditText of webpage.
Thanks
here is java code:
wv_load.addJavascriptInterface(new Object()
{
#JavascriptInterface
public void performClick(String strName,String strAge,String strEmail)
{
Toast.makeText(WebActivity.this, "Input Provided "+strName+" "+strAge+" "+strEmail, Toast.LENGTH_LONG).show();
}
}, "valid");
and html with javascript code:
<html>
<head>
<script language="javascript">
var at;
var age;
var name;
function validClick()
{
at = document.getElementById("email").value;
age = document.getElementById("age").value;
name = document.getElementById("name").value;
document.getElementById('lbl').innerHTML = '';
document.getElementById('lbl2').innerHTML = '';
document.getElementById('lbl3').innerHTML = '';
var ret=myValidation();
if(ret==true){
valid.performClick(name,age,at);
document.getElementById('lbl').innerHTML = '';
document.getElementById("demo_form").reset();
}else{
}
}
function myValidation() {
submitOK = "true";
if (!validateName(name)) {
document.getElementById('lbl').innerHTML = 'Enter Full Name!';
submitOK = "false";
}
if (isNaN(age) || age < 1 || age > 100) {
document.getElementById('lbl2').innerHTML = 'Enter Valid Age!';
submitOK = "false";
}
if (!validateEmail(at)) {
document.getElementById('lbl3').innerHTML = 'Enter Valid Email!';
submitOK = "false";
}
if (submitOK == "false") {
return false;
}
else{
return true;
}
}
function validateName(name){
var reName=/^(([A-Za-z]+[\-\']?)*([A-Za-z]+)?\s)+([A-Za-z]+[\-\']?)*([A-Za-z]+)?$/;
return reName.test(name);
}
function validateEmail(at) {
var re = /^(([^<>()[\]\\.,;:\s#\"]+(\.[^<>()[\]\\.,;:\s#\"]+)*)|(\".+\"))#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(at);
}
</script>
</head>
<body>
<form name="demo_form" id="demo_form">
Name : <input type="text" id="name" style="margin-left: 16px;" size="20">
<label id="lbl" style="color:red"></label><br>
Age : <input type="text" id="age" style="margin-left: 30px;" size="20">
<label id="lbl2" style="color:red"></label><br>
Email: <input type="text" id="email" style="margin-left: 22px;" size="20">
<label id="lbl3" style="color:red"></label><br><br>
<div>
<button type="button" id="ok" style="font-weight: 700; margin-left: 70px;"
onclick="validClick();">Submit
</button>
</div>
</form>
</body>
</html>
So I have this form where upon submission I do a SQL query and redirect it to another page. But when I try to test this on the android tablet it doesnt redirect, nor does it error meaning the SQL call is valid and works...can someone please help me out
<div class="wrapper">
<div class="oneSection">
<form method="post" action="" id="barcodeForm">
Barcode: <br/>
<input name="barcode" id="barcode" type="text" class="sub"/><br/>
<input type="submit" class="open" id="before" value="SUBMIT" onclick="check()" />
</form>
</div>
</div>
<script type="text/javascript">
function check() {
var barcode = $('#barcode').val();
if(barcode.length <= 0) {
$('#barcode').css('border', '2px solid red');
e.preventDefault();
return;
} else {
alert(barcode.length);
var barcode = $('#barcode').val();
checkBarcode(false, barcode);
}
}
function checkBarcode(doAuto, id) {
var successCall;
if (doAuto) {
successCall = function (tx, result) {
var item = result.rows.item(0);
$('[name="client"]').val(item['cname']);
$('[name="address"]').val(item['address']);
$('[name="sitename"]').val(item['sname']);
$('[name="model"]').val(item['model']);
$('[name="lasttested"]').val(item['ltest']);
$('[name="nounits"]').val(item['units']);
$('[name="comments"]').val(item['comments']);
}
} else {
test.innerHTML += 'at the start<br/>';
successCall = function () {
var URL = 'test.html?id=' + id;
window.location.href = URL;
}
}
var queryDB = function queryDB(tx) {
tx.executeSql(getBarcode, [id], successCall, onError);
}
db.transaction(queryDB, onError);
}
</script>
What happens at the moment is that it submit's the input value and resets the form without forwarding the page or anything...
I am developing one application in PhoneGap in that application i want to share text-message in Facebook,twitter and LinkedIn. for ANDROID-LinkedIn i am searching many Google links but i am getting good one. please help me i am struck here
I am implementing this sample:
<html>
<head>
<title>OAuthSimple w/ LinkedIn</title>
<script src="OAuthSimple.js"></script>
<script>
/*
You must edit the two following lines and put in your consumer key and shared secret
*/
var consumer_key = "ibmay1qostgk";
var shared_secret = "4HqeDRZ2ZKAvASlM";
/*
Nothing below here needs to be edited for the demo to operate
*/
var oauth_info = {};
var oauth = OAuthSimple(consumer_key, shared_secret);
function parse_response(response, callback)
{
response.replace(new RegExp("([^?=&]+)(=([^&]*))?", "g"), function($0, $1, $2, $3) { oauth_info[$1] = $3; });
callback.call();
}
function authorize_url()
34{
set_url("https://www.linkedin.com/uas/oauth/authenticate?oauth_token=" + oauth_info.oauth_token, document.getElementById("au"));
}
function access_token_url(pin) {
oauth.reset();
var url = oauth.sign({action: "GET", path: "https://api.linkedin.com/uas/oauth/accessToken", parameters: {oauth_verifier: pin}, signatures: oauth_info}).signed_url;
set_url(url, document.getElementById("at"));
}
function fetch_profile_url() {
oauth.reset();
var url = oauth.sign({action: "GET", path: "https://api.linkedin.com/v1/people/~", signatures: oauth_info}).signed_url;
set_url(url, document.getElementById("fp"));
}
function set_url(url, element) {
element.value = url;
var span = document.createElement("span");
span.innerHTML = " <a href='" + url + "' target='_blank'>Open</a>";
element.parentNode.insertBefore(span, element.nextSibling);
}
window.onload = function() {
var url = oauth.sign({action: "GET", path: "https://api.linkedin.com/uas/oauth/requestToken", parameters: {oauth_callback: "oob"}}).signed_url;
set_url(url, document.getElementById("rt"));
}
</script>
</head>
<body>
<h1>OAuthSimple w/ LinkedIn</h1>
<label for="rt">Request Token URL:</label> <input type="text" size="100" name="rt" id="rt" >
<br><br>
<label for="rtr">Request Token Response:</label><br><textarea rows="5" cols="75" name="rtr" id="rtr"></textarea>
<br>
<button onclick="javascript:parse_response(document.getElementById('rtr').value, authorize_url)">Parse Response</button>
<br><br>
<label for="au">Authorize URL:</label> <input type="text" size="100" name="au" id="au">
<br><br>
<label for="vp">Verifier PIN Code:</label> <input type="text" size="100" name="vp" id="vp">
<button onclick="javascript:access_token_url(document.getElementById('vp').value)">Get Access Token URL</button>
<br><br>
<label for="at">Access Token URL:</label> <input type="text" size="100" name="at" id="at">
<br><br>
<label for="atr">Access Token Response:</label><br><textarea rows="5" cols="75" name="atr" id="atr"></textarea>
<br>
<button onclick="javascript:parse_response(document.getElementById('atr').value, fetch_profile_url)">Parse Response</button>
<br><br>
<label for="fp">Fetch Profile URL:</label> <input type="text" size="100" name="fp" id="fp">
</body>
</html>
thanks in advance
Heres a full example of login and sending msg linkedIn using Phonegap
ref = window.open('https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=APIKEY&scope=w_messages r_network r_emailaddress r_fullprofile&state=APISECRET&redirect_uri=SOMEACTIVESITE','_blank','location=no');
ref.addEventListener('loadstart', function(e){
$.mobile.loading( 'show' );
if(e.url.indexOf('?code=') >=0 ){
if(e.url.match(/=[^]+&/)){
var code = e.url.match(/=[^]+&/)[0].substring(1).replace('&','');
window.sessionStorage.setItem('code', code);
ref.close();
$.ajax({
url: 'https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code='+code+'&redirect_uri=http://janbeeangeles.com&client_id=jwwwdjplwubu&client_secret=ygMy3EpVcs6IAORE',
success: function(a){
$.ajax({
url : 'https://api.linkedin.com/v1/people/~/mailbox?oauth2_access_token='+a.access_token,
type: 'post',
headers : {
'Content-Type' : 'application/json',
'x-li-format' : 'json'
},
data: JSON.stringify({
"recipients": {
"values": [
{
"person": {
"_path": "/people/~",
}
}]
},
"subject": "asdasdasd on your new position.",
"body": "You are certainly the best person for the job!"
}),
success: function(a){
alert(2222)
},
error: function(a){
alert(JSON.stringify(a))
}
})
},
error: function(a){
alert(JSON.stringify(a))
}
})
}
}
});
I'm trying to send a getJson call from my app (login form) to get an external JSON from PHP file. and there if login and password are ok. My app will redirect from login.html to home.html.
This is my script located in login.html shown below
<script>
function testlogin() {
var login = $('#login').val();
var password = $('#password').val();
$.ajax({
url: "http://http://10.0.2.2/YasmineMarket.php",
data: { login: JSON.stringify(login), password: JSON.stringify(password) },
dataType: "jsonp",
success: function(json, textstatus) {
if (json.d == 'Login Success') {
var url = "acceuil.html";
$(location).attr('href', url);
}
else {
alert("Wrong Username or password");
var url = "index.html";
$(location).attr('href', url);
}
},
error: function(xmlHttpRequest, textStatus, errorThrown) {
if (xmlHttpRequest.readyState == 0 || xmlHttpRequest.status == 0)
return;
else
alert(errorThrown);
}
});
}
</script>
<!DOCTYPE HTML>
<html >
<form id="loginForm" method="GET" >
<table border="0" align="center">
<tr><td></td></tr>
<tr><td align="center"><input type="text" name="login" id="login" /></td></tr>
<br>
<tr><td align="center"><input type="password" name="password" id="password" /></td></tr>
<tr><td align="center"><input type="submit" value="Connexion" onlick="testlogin();" class="button" /></td></tr>
</table>
</form>
</body>
This code is not sufficient to find the actual problem here. But this link might help you to write a server authentication. Please go through my old post about jsonp ajax request to a web server using jquery mobile and phonegap.