Search code examples
groovygoogle-apiopenid-connecthttp-status-code-302

Implementation of GoogleAPi Authentication


I'm trying to implement the OpenID authentication for Google APIs, according to Google documentation:

I'm having trouble in the second step when sending the authentication request to Google. In the response I'm not receiving the code that Google is supposed to send me. This is my code:

def client = new RESTClient("https://accounts.google.com/o/oauth2/auth")

def p   = [
                scope:  scope,
                state: "security_token="+state,
                redirect_uri:   redirecturi,
                response_type:  responsetype,
                client_id:      clientID,       
                ignoreSSLIssues: true,                  
            ]

def response =  client.post ( body : p,
                            contentType : URLENC)       

I made sure all of the parameters are correct, but in the response I'm getting Status 302 and I'm not receiving the code.

I'm only having doubts with the redirect_uri, I'm using this one:

https://developers.google.com/oauthplayground


Solution

  • Your server can't make an HTTP request to that URL, it needs to be opened in the browser by the user who will be authenticating. Be sure to read through the authentication docs.