Google oauth2 api client is not working properly

后端 未结 1 655
情歌与酒
情歌与酒 2021-01-06 03:08

Hi guys I have some code in my grails 2.3.4\'s controller\'s action that uses google java client libraries to access the OAuth2 api. But when I create an instance of GoogleA

1条回答
  •  天涯浪人
    2021-01-06 03:19

    Okey I've found the solution.

    When you create new LocalServerReceiver() use instead new LocalServerReceiver.Builder().setPort(9089).build()

    I've chosen some empty port in this case 9089. Actually LocalServerReceiver is a http server that listens to google and google sends code param to this server. Now all you have to do is create a new entry in your Redirected URIs which is in this case as follows: http://localhost:9089/Callback. Note the port number is same as I've used in the code while building the server using LocalServerReceiver.Builder() class.

    And voila!!! you got the access_token and refresh_token from the google.

    Happy coding... Happy Java clients...

    0 讨论(0)
提交回复
热议问题