OAuth2 invalid_request error.

3,481 views
Skip to first unread message

Ankit Kavi

unread,
Dec 4, 2012, 1:17:10 PM12/4/12
to oauth...@googlegroups.com
So I am trying to run the python script (oauth2.py) that google mail api offers as a tool. 

When I run this script and get the redirect url address I get the following error:

Error: invalid_request

Invalid parameter value for redirect_uri: Missing authority: urn:ietf: wg:oauth:2.0:oob

Request Details

Does anyone know why this would occur or have a fix for this error?
Thank you!

David Coombes

unread,
Dec 4, 2012, 1:20:45 PM12/4/12
to oauth...@googlegroups.com

Are you definitely using the same uri redirect value that you set up when creating the app?

--
 
 

Ankit Kavi

unread,
Dec 4, 2012, 1:31:22 PM12/4/12
to oauth...@googlegroups.com
Yes I am. The uri redirect is linked the the default uri generated when creating an installed app client id:
    urn:ietf:wg:oauth:2.0:oob

David Coombes

unread,
Dec 4, 2012, 1:40:53 PM12/4/12
to oauth...@googlegroups.com

Generally when I set up an app the redirect is in the format http:example.com?foo=bar

Not sure where your getting that value from

--
 
 

Ankit Kavi

unread,
Dec 4, 2012, 1:44:16 PM12/4/12
to oauth...@googlegroups.com
That is the redirect uri i got from my API Access linked to my API Project on code.google.com after creating an installed application client id and secret.

They give two redirect uris:
urn:ietf:wg:oauth:2.0:oob http://localhost

The link in my original post has a download link for the script I am trying to use. In this script the redirect uri is set to the first of the two available uris.

Vladimir Kolovski

unread,
Dec 4, 2012, 4:54:54 PM12/4/12
to oauth...@googlegroups.com
Hi Ankit,

The redirect uri (urn:ietf:wg:oauth:2.0:oob) looks fine - just make sure there isn't an extra space in there. Can you please share some more information? At what step here does it fail?

Vladimir

--
 
 

Ankit Kavi

unread,
Dec 4, 2012, 5:02:28 PM12/4/12
to oauth...@googlegroups.com
I can get the script to work fine. When I go to the url that it spits out I get the error that is in my first post. I did not make any changes to the python script EXCEPT adding an import for encodings.

Essentially I cannot get past "Creating and Authorizing an OAuth Token"

Vladimir Kolovski

unread,
Dec 4, 2012, 5:12:27 PM12/4/12
to oauth...@googlegroups.com
Can you please post the url that's produced by the script? FYI, I just tried running it on my machine, with your client ID, I was able to see the consent page.

Vladimir

--
 
 

Ankit Kavi

unread,
Dec 4, 2012, 5:14:55 PM12/4/12
to oauth...@googlegroups.com

Vladimir Kolovski

unread,
Dec 4, 2012, 5:21:31 PM12/4/12
to oauth...@googlegroups.com
I still can't reproduce this, the URI checks out. As I implied before, you seemed to have an extra space in the redirect URI in your first post.

Vladimir

--
 
 

Ankit Kavi

unread,
Dec 5, 2012, 9:09:39 AM12/5/12
to oauth...@googlegroups.com
An extra space in the python script? I double checked that and it does not seem like I do...

Ankit Kavi

unread,
Dec 5, 2012, 4:17:44 PM12/5/12
to oauth...@googlegroups.com
Oddly, when I clicked the link I sent you above I was able to get a token.

Ankit Kavi

unread,
Dec 5, 2012, 4:21:47 PM12/5/12
to oauth...@googlegroups.com
And now it won't work again. This is very odd.

Ankit Kavi

unread,
Dec 5, 2012, 5:25:43 PM12/5/12
to oauth...@googlegroups.com
So now I am failing at testing IMAP and SMTP authentication. I get the following error and trace:

Traceback (most recent call last):
  File "oauth2.py", line 333, in <module>
    main(sys.argv)
  File "oauth2.py", line 320, in main
    base64_encode=False))
  File "oauth2.py", line 266, in TestImapAuthentication
    imap_conn.authenticate('XOAUTH2', lambda x: auth_string)
  File "C:\Python27\lib\imaplib.py", line 351, in authenticate
    raise self.error(dat[-1])
imaplib.error: [ALERT] Invalid credentials (Failure)

David Coombes

unread,
Dec 5, 2012, 5:28:12 PM12/5/12
to oauth...@googlegroups.com

Could be wrong but I've no idea how the call back url you were using was ever going to work

--
 
 

Ankit Kavi

unread,
Dec 6, 2012, 12:15:04 PM12/6/12
to oauth...@googlegroups.com
That doesn't really help me solve this problem....
Reply all
Reply to author
Forward
0 new messages