Этот вопрос находится в в последующих до моего предыдущего вопросаGoogle OAuth Java клиент, чтобы получить маркер доступа терпит неудачу с «400 Bad Request {» Ошибка «:» invalid_request «}»
Я нырнула в API JAVA, чтобы решить проблему обмена кодом для authToken в API oAuth Google, но не смог найти ответа. Таким образом, я пошел очень упрощенным путем.
Я создал следующие JSPs
index.jsp
<%@page import="java.net.URLEncoder"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<a href="https://accounts.google.com/o/oauth2/auth?
scope=https://gdata.youtube.com/&
redirect_uri=<%=URLEncoder.encode("http://localhost:8080/BroadCastr/step2.jsp","UTF-8")%>&
response_type=code&
client_id=X985XXXXXXXX.apps.googleusercontent.com&approval_prompt=force">Connect google account</a>
</body>
</html>
Эта страница представленной мне с простой ссылкой на «Connect Google аккаунт», который привел меня успешно на страницу Googles, где я должен был «Разрешить» мой приложение для доступа к YouTube от моего имени
в step2.jsp
<%@page import="java.net.URLEncoder"%>
<%@page import="java.util.Iterator"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form id="frm" method="post" action="https://accounts.google.com/o/oauth2/token" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="code" value="<%=URLEncoder.encode(request.getParameter("code"),"UTF-8")%>"/>
<input type="hidden" name="client_id" value="XXXXXXXXXXX.apps.googleusercontent.com"/>
<input type="hidden" name="client_secret" value="XXXXxxxxXXXXXX"/>
<input type="hidden" name="redirect_uri" value="<%=URLEncoder.encode("http://localhost:8080/BroadCastr/step3.jsp","UTF-8")%>"/>
<input type="hidden" name="grant_type" value="authorization_code"/>
<input type="hidden" name="scope" value=""/>
</form>
</body>
</html>
<script>
document.getElementById("frm").submit();
</script>
Но в конце концов step2.jsp представляет себя на сервер Google, все, что я получаю следующий бесполезных JSON
{
"error": "invalid_request"
}
Я действительно будет признателен за любую помощь на этом.
Можете ли вы отправить запрос на отправку в Google? некоторый захват скрипача – Vlad