oauth-io / oauth-phonegap

OAuth.io plugin for Apache Cordova/PhoneGap
195 stars 69 forks source link

Instagram & Google API Issues #60

Closed daksamedia closed 9 years ago

daksamedia commented 9 years ago

Hello there,

Problem : I wasn't able to get user details on both providers (Instagram & Google)

To make you get easier to help me, here's my code.

INSTAGRAM LOGIN
$('#ig').on('touchstart', function() { 
                    $('#result').html("");
                    OAuth.popup('instagram')
                        .done(function (r) {
                            // the access_token is available via r.access_token
                            // but the http functions automagically wrap the jquery calls
                            r.get('https://api.instagram.com/v1/users/self/?access_token='+r.access_token)
                                .done(function(data) {
                                    $('#myname').html(data.name);
                                    $('#mypict').attr("src",data.profile_picture);
                                    $('#login').hide();
                                    $('#congratulation').show();
                                })
                                .fail(function( jqXHR, textStatus, errorThrown) {
                                    $('#result').html("req error: " + textStatus);
                                });
                        })
                        .fail(function (e) {
                            $('#result').html('error: ' + e.message);
                        });
                });

GOOGLE PLUS LOGIN
                $('#gp').on('touchstart', function() {
                    $('#result').html("");
                    OAuth.popup('google_plus')
                        .done(function (r) {
                            // the access_token is available via r.access_token
                            // but the http functions automagically wrap the jquery calls
                            r.get('https://www.googleapis.com/plus/v1/people/me')
                                .done(function(data) {
                                    $('#myname').html(data.name);
                                    $('#mypict').attr("src",data.imageUrl);
                                    $('#login').hide();
                                    $('#congratulation').show();
                                })
                                .fail(function( jqXHR, textStatus, errorThrown) {
                                    $('#result').html("req error: " + textStatus);
                                });
                        })
                        .fail(function (e) {
                            $('#result').html('error: ' + e.message);
                        });
                });

Thanks in advance.

Best Regards