简体   繁体   English

错误 400:redirect_uri_mismatch - Google 计算机引擎 - nginx - SpringBoot - google OAuth

[英]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 and代码中的https://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.

相关问题 谷歌:“错误 400:redirect_uri_mismatch” - Google: "Error 400: redirect_uri_mismatch" 错误 400:redirect_uri_mismatch - 谷歌云 api - Error 400: redirect_uri_mismatch - Google cloud api 我收到此错误:- 错误 400: redirect_uri_mismatch 即使我在 Google Gmail API OAuth 2.0 中注册了 URI - I get this error:- Error 400: redirect_uri_mismatch even after I registered the URI in Google Gmail API OAuth 2.0 出现错误 400:cognito idp 设置中的 redirect_uri_mismatch - Getting Error 400: redirect_uri_mismatch in cognito idp settings 正确的 Google API 和 OAuth 2.0 重定向 URI - Correct redirect URI for Google API and OAuth 2.0 Google Cloud 重定向 URI 不匹配 - Google Cloud redirect URI missmatch http -> https 在 Google Kubernetes 引擎中重定向 - http -> https redirect in Google Kubernetes Engine redirect_uri: http://XXX.herokuapp.com/auth/google/callback 错误 - redirect_uri: http://XXX.herokuapp.com/auth/google/callback error nginx 入口 controller 忽略 css 和 js 文件 - 谷歌 kuber.netes 引擎 - nginx ingress controller ignoring css and js files - google kuberenetes engine 弹性 APM 错误 | 谷歌 Kubernetes 引擎 - Elastic APM Error | Google Kubernetes Engine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM