Error: invalid_request - invalid parameter for redirect_uri: Missing authority

1.7k views Asked by At

I've been working on and off for a few months on getting hello.js to work with my PhoneGap application.

Just focusing on Google for now, and when I get redirected in the PhoneGap browser, I'm sent to a 400 error;

Error: invalid_request
invalid parameter for redirect_uri: Missing authority
file:///android_asset/www/index.html

I've followed instructions on various sites to help with set up, but nothing seems to get me past this error.

My button:

<button onclick="hello( 'google' ).login()">google</button>

My javascript:

<script type="text/javascript" src="js/hello.all.js"></script>
<script>
    hello.on('auth.login', function(auth){
        // call user information, for the given network
        hello( auth.network ).api( '/me' ).success(function(r){
            var $target = $("#profile_"+ auth.network );
            if($target.length==0){
                $target = $("<div id='profile_"+auth.network+"'></div>").appendTo("#profile");
            }
            $target.html('<img src="'+ r.thumbnail +'" /> Hey '+r.name).attr('title', r.name + " on "+ auth.network);
        });
    });
    hello.init({ 
        google   : 'MY_CLIENT_ID_IS_HERE.apps.googleusercontent.com'
    },{redirect_uri:'TRIED_VARIOUS_THINGS_HERE'});
</script>

I've tried a redirect url of http:// localhost (without the space as it is here) I've tried a redirect url of urn:ietf:wg:oauth:2.0:oob I've tried a redirect url of only oob

Google says my redirect URIS are

REDIRECT URIS  
urn:ietf:wg:oauth:2.0:oob
http://localhost

When speaking with Andrew Dodson, who I assume is the creator of hello.js he said:

Its like redirect_uri hasn't been set, it defaults to window.location.href, 

He assured me that jQuery wasn't needed, but I was curious why the reference to var $target = $("#profile_"+ auth.network ); in the example code?

I don't use jQuery, and prefer just a Javascript solution. Is there someone who can explain the purpose of the $("... in the code above, and how I might use different code in it's place?

Thanks so much

0

There are 0 answers