Cannot complete authorization - linkedin-api

I've got LinkedIn API app created and I'm able to get to the 'Allow' screen. That redirects to a form on my site which is submitted to linkedin.com to complete the authorization.
Instead of redirecting to my redirect url I'm getting an error saying:
"You must be authenticated to access this page".
Below is the form I'm submitting except that I've replaced the form field values with fakes.
I've made sure the real redirect URL is authenticated in my LinkedIn application.
What am I doing wrong?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SoftLink Systems LinkedIn Auth Completion</title>
</head>
<body>
<form id="frmLNAuthComplete" action="https://www.linkedin.com" enctype="application/x-www-form-urlencoded" method="post" >
<input type="hidden" name="grant_type" value="authorization_code" />
<input type="hidden" name="code" value="FAKE_CODE_Gdy1R3cW2hFACX2dV39QwfofGVXg6v1nPH0O_Em4UnzEaR06ZXDGO57HU0DukpehS-EGu-AzF3L8SG8XfrB6oYRkpPtY3cLc" />
<input type="hidden" name="redirect_uri" value="http://linkedin.fake-domain.com/index.php" />
<input type="hidden" name="client_id" value="fake-id-k66l" />
<input type="hidden" name="client_secret" value="fake-secret-rI2mxlqb" />
</form>
<script type="application/javascript">
var frm = document.querySelector("#frmLNAuthComplete");
frm.submit();
</script>
</body>
</html>

Related

expression language in jstl if statement not working

I am trying to understand why this piece of code never prints the method request when run on tomcat 9:
<%# page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<title>Add Course</title>
</head>
<body>
<c:if test="${\"POST\".equalsIgnoreCase(pageContext.request.method) && pageContext.request.getParameter(\"submit\") != null}">
<%= request.getMethod() %>
</c:if>
<form method="post">
Name: <input type="text" name="name"> <br>
Credits : <input type="text" name="credits"> <br>
<button type="submit" name="submit">Add</button>
</form>
</body>
</html>
I don't have Tomcat 9 currently installed on my system, but it runs fine in Tomcat 8.5, and Jetty 9.4.17 printing "POST" whenever I post the form.
However, el language, despite resembling Java in many aspects and being able to call Java functions is NOT actually Java. You will encounter more success and consistency using it in a more idiomatic way. In your case, I'm pretty sure the following will work on any up-to-date JSP server:
<%# page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
<title>Add Course</title>
</head>
<body>
<c:if test="${'post' eq fn:toLowerCase(pageContext.request.method) and param.submit ne null}">
${pageContext.request.method}
</c:if>
<form method="post">
Name: <input type="text" name="name" /><br />
Credits: <input type="text" name="credits" /><br />
<button type="submit" name="submit">Add</button>
</form>
</body>
</html>
Using the fn taglib to compare strings in lower case
Using single quotes around strings to avoid escaping
Using el eq and ne operators for "equals" and "not equals"
Using el and boolean operator
Using el variable param to access request parameters
Using ${...} syntax to output values rather than scriptlets

How to include properly a css file in jsp

I tried this :
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" />
but the css won't apply. :(
Am i missing something obvious ?
EDIT :
Here is my jsp :
<%# page pageEncoding="utf-8"%>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Log-in</title>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" />
</head>
<body>
<div class="login-card">
<h1>Log-in</h1><br>
<form>
<input type="text" name="user" placeholder="Username">
<input type="password" name="pass" placeholder="Password">
<input type="submit" name="login" class="login login-submit" value="login">
</form>
<div class="login-help">
Register • Forgot Password
</div>
</div>
</body>
</html>
Try this:- <jsp:include page="style.css"/>
Using the include directive should do the trick.
<link type="text/css" rel="stylesheet" href="css/style.css"/>
try this, will work. In java it ma

PayPal embedded flow: Payment can't be completed. This feature is currently unavailable

I'm trying to get the example shown here to work:
https://developer.paypal.com/webapps/developer/docs/classic/adaptive-payments/ht_ap-embeddedPayment-curl-etc/
However, I always get the error Payment can't be completed. This feature is currently unavailable.
This is the code, taken directly from PayPal's documentation (where {{PAY-KEY}} is a pay key you obtain from PayPal):
<html>
<head>
<script src="https://www.paypalobjects.com/js/external/apdg.js" type="text/javascript"></script>
</head>
<body>
<form action="https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay" target="PPDGFrame" class="standard">
<label for="buy">Buy Now:</label>
<input type="image" id="submitBtn" value="Pay with PayPal" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif">
<input id="type" type="hidden" name="expType" value="mini">
<input id="paykey" type="hidden" name="paykey" value="{{PAY-KEY}}">
</form>
<script type="text/javascript" charset="utf-8">
var dgFlowMini = new PAYPAL.apps.DGFlowMini({trigger: 'submitBtn'});
</script>
</body>
</html>
The same error occurs when you try to use this for Preapproval ([...]/flow/preapproval, request variable preapprovalKey), and also with the LightBox code sample.
What am I missing here ?
Contacted PayPal support and they apparently fixed it (again...).

Form remain the same after submiting using jquery mobile

After Im using jquery mobile to submit a form,
but after submition, and going back to form, all fields are not in default value any more. they showing data previously submitted.
(if I press f5, form will reset and works fine for another round only)
Im guessing something remain in browser cache.
Any Idea?
<!DOCTYPE html>
<html>
<head>
<script src="scripts/jquery-1.9.1.min.js"></script>
<script src="./scripts/jquery.mobile-1.3.0.js"></script>
<link rel="stylesheet" href="./style/jquery.mobile-1.3.0.min.css" />
</head>
<body>
<?php if(!(isset($_GET["submit"]))){ ?>
<form action="thisPage.PHP?submit=yes" method="get" >
<input type="text" value="0" />
<input type="submit" value="Submit" />
</form>
<?php }else{ ?>
<a href="thisPage.PHP" > FINISHED</a>
<?php } ?>
</body>
</html>
Finally I found the simple and easy answer:
add following line into form tag:
data-ajax="false"
so it should be like this:
<form action="thisPage.PHP?submit=yes" method="get" data-ajax="false" >

J_scurity_check fails in Firefox 4

The applications works fine in Firefox3.6 ,all versions of IE. I downloaded Firefox 4 and tried to login. When I entered user name and password and click on submit button, It just clears the labels and when I hit on refresh button it submits the form. If I enter wrong userid and password it redirects to the error page.
<form method="POST" action="j_security_check">
Username: <input type="text" name="j_username"> <br/>
Password: <input type="password" name="j_password">
<input type="submit" value="Login">
</form>
There are no error messages in the logs.
I still have no clue about your problem as you do not give much details about your environment and application. Do you use any javascript or ajax in your login page for example? Do you have some mal formed tags between tags?
In my case, I am using java-ee-5, JSF 2.0 framework (My login page works in Firefox 3.6, Opera 11 and IE8 but not in Google Chrome)
Here is my working login page (tested on Firefox 3.6.17 and 4.0.1).
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:o="http://openfaces.org/">
<h:head>
<div align="center">
<h:outputText value="Logon"
style="text-align: center;font-weight: bolder"/>
<br />
</div>
<h:outputStylesheet name="css/style.css"/>
<link rel="icon" href="#{resource['images/diagnostic.ico']}" type="image/x-icon"/>
<link rel="shortcut icon" href="#{resource['images/diagnostic.ico']}" type="image/x-icon"/>
</h:head>
<h:body style="font-weight: lighter;background: url(#{resource['images/master-bg.jpg']});background-repeat: repeat;">
<h:form id="logonform" onsubmit="document.logonform.action = 'j_security_check';">
<p:panel header="#{bundle.Login}" style="font-weight: lighter">
<h:panelGrid columns="2">
<h:outputLabel for="j_username" value="#{bundle.Username}" style="font-weight: bold;"/>
<input id="usernameid" type="text" name="j_username" />
<h:outputLabel for="j_password" value="#{bundle.Password}" style="font-weight: bold;"/>
<input type="password" name="j_password" />
<h:outputText value="" />
<h:panelGrid columns="2">
<p:commandButton value="Connexion" type="submit" ajax="false"/>
<p:button outcome="Logon" value="Cancel" />
</h:panelGrid>
</h:panelGrid>
</p:panel>
</h:form>
</h:body>
</html>
I used the same plain html form as you and it is working for me too in Firefox 4.0.1 and even better than 3.6.17.
I am also seeking an answer to this problem. I am developing a JavaEE6/JSF2 web application that runs inside Glassfish (first 3.0.1 and now 3.1).
The FORM based login was working fine on Firefox3.x versions, and still works fine on Safari5.0.5, but "fails silently" on both Firefox4.0.1 and on Google Chrome 12.0.742.91. (I am on Mac OS X and have not checked IE.)
It is very difficult to provide diagnostics since there are none.
Q: Are there any other logs or possible source of diagnostics I can switch on for Firefox and/or Google Chrome that might throw light in the subject ?
Here is my form:
<form id="loginForm" method="POST" action="j_security_check">
<h:panelGrid columns="3" styleClass="login" columnClasses="login-label, login-field">
<h:outputLabel for="j_username">Username:</h:outputLabel>
<h:inputText id="j_username" required="true" />
<h:message for="j_username" />
<h:outputLabel for="j_password">Password:</h:outputLabel>
<h:inputSecret id="j_password" required="true" />
<h:message for="j_password" />
<h:outputLabel for="login_button"></h:outputLabel>
<h:commandButton id="login_button" value="Login" />
</h:panelGrid>
This is similar to examples shown elsewhere that are claimed to be compatible with Firefox 4, such as from here (to respect copyright conditions not copied here, please examine external link then return):
enter link description here
That login form is claimed to be compatible with Mozilla Firefox 4, Internet Explorer 8, Chrome 11. Safari 5, Opera 11. But I can't see that it is very different from my own.