[英]Error 400: redirect_uri_mismatch - Google Computer Engine - nginx - SpringBoot - google OAuth
I have a spring boot app running on 8080 (not https as I am not sure if this also need https enabled) There is an nginx server that redirects requests from 80 (or 443/8443) to 8080 I have a spring boot app running on 8080 (not https as I am not sure if this also need https enabled) There is an nginx server that redirects requests from 80 (or 443/8443) to 8080
The nginx is secured using letsencrypt. nginx 使用letsencrypt进行保护。 I see this domain file in sites-enabled folder
我在启用站点的文件夹中看到此域文件
created certificate using使用创建的证书
sudo certbot --nginx -d {dom}.co.uk -d www.{dom}.co.uk
server {
root /var/www/{mydomain}.co.uk/html;
index index.html index.htm index.nginx-debian.html;
server_name {mydomain}.co.uk www.{mydomain}.co.uk;
location / {
#try_files $uri $uri/ =404;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass "http://127.0.0.1:8080";
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/{mydomain}.co.uk/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/{mydomain}.co.uk/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.{mydomain}.co.uk) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = {mydomain}.co.uk) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name {mydomain}.co.uk www.{mydomain}.co.uk;
return 404; # managed by Certbot
} }
OAuth 2 settings OAuth 2 设置
In OAuth Credentials在 OAuth 凭证中
Authorized Javascript urls (For use with requests from a browser)授权的 Javascript url(用于来自浏览器的请求)
https://{dom}.co.uk https://{dom}.co.uk
Authorized redirect URIs (For use with requests from a web server)授权的重定向 URI(用于来自 web 服务器的请求)
https://{dom}.co.uk/login/oauth2/code/google https://{dom}.co.uk/login/oauth2/code/google
Configured redirect URL配置重定向 URL
private static API_BASE_URL = "https://{dom}.co.uk/";
private static OAUTH2_URL = AppConstants.API_BASE_URL + "oauth2/authorization/";
Question :问题:
How to fix my如何修复我的
Authorisation Error Error 400: redirect_uri_mismatch授权错误错误 400:redirect_uri_mismatch
Do I need to make my spring app also https enabled我是否需要让我的 spring 应用程序也启用 https
(OR) (或者)
Any config issue nginx or redirect url etc?任何配置问题 nginx 或重定向 url 等?
The redirect_uri
you send to Google when initiating the flow must match what you put in the console.您在启动流程时发送给 Google 的
redirect_uri
必须与您在控制台中输入的内容相匹配。
Here you have:在这里你有:
https://example.co.uk/oauth2/authorization/
in the code andhttps://example.co.uk/oauth2/authorization/
和https://example.co.uk/login/oauth2/code/google
in the console. https://example.co.uk/login/oauth2/code/google
在控制台中。 Change either one to match the other.更改其中一个以匹配另一个。 I suggest that you change your code to avoid waiting a good 5 minutes for the changes in the console to propagate.
我建议您更改代码以避免等待 5 分钟让控制台中的更改传播。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.