Retrieval/Changing of Profile Picture Google Profile API

1.2k views Asked by At

I am able to retrieve profile information via an AJAX call in Jquery using this code:

var url = 'https://www.google.com/m8/feeds/profiles/domain/{DOMAIN_NAME}/full';
        $.ajax({
            url: url
                +'?access_token='
                +accessToken,
            headers: {
                'GData-Version': '3.0',
                'If-Match': '*'
            },
            async: false,
            dataType: 'text',
            success: function(data) {
                $('#result').text(data);
            }
        });
    };

However when I try to retrieve a picture with the same access token:

var url = 'https://www.google.com/m8/feeds/profiles/domain/{MY_DOMAIN}/full/{USER_NAME}';   
        $.ajax({
            url: url
                +'?access_token='
                +accessToken,
            headers: {
                'GData-Version': '3.0'
            },
            async: false,
            dataType: 'text',
            success: function(data) {
                $('#result').text(data);
            }
        });

I get the error: 401 (Token invalid - AuthSub token has wrong scope)

The scope I'm using is the one provided on the profile data api page: https://www.google.com/m8/feeds/profiles

How do I get the correct authorization? Does the access token provided not do the job?

2

There are 2 answers

0
Suhail Ansari On

Try using this path as scope

https://www.google.com/m8/feeds/

You can refer this post

0
Emily On

For profile pictures, I believe the URL of the form should be

https://www.google.com/m8/feeds/photos/profile/domainName/userName

Here is the documentation: https://developers.google.com/google-apps/profiles/#retrieving_photo

Would you try that and see if it works?