Google OAuth token exchange returns invalid_code

后端 未结 2 465
醉酒成梦
醉酒成梦 2021-02-13 14:56

I have been implementing the Google web server OAuth flow, but when I attempted to exchange the authorization code with access token, it always complains \"invalid_code\".

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-13 15:28

    I was using http://localhost:8080 as my redirect url since I was just trying out their examples. And my json file contents had this:

    "redirect_uris": [
      "http://localhost:8080"
    ],
    "javascript_origins": [
      "http://localhost:8080"
    ]
    

    In the developer console I had the redirect_uri set to "http://localhost:8080" and I was getting the same error. I changed it to "http://localhost:8080/" and then it started working. (Essentially adding a '/' at the end.)

    Hope this helps!

提交回复
热议问题