我有使用firebase访问Google Contacts API的代码。 它对用户进行身份验证并返回access_token,但它似乎无法访问Contacts API(我使用的是AngularFire)。这是代码:
var ref = new Firebase("<<FIREBASE-APP>>");
$scope.click = function() {
ref.authWithOAuthPopup("google", function (error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
console.log(authData.google.accessToken);
var resource = "https://www.google.com/m8/feeds/contacts/default/full?alt=json&access_token=" + authData.google.accessToken;
$.getJSON(resource,function (response) {
console.log(resource);
});
}
收到的错误是: https://www.google.com/m8/feeds/contacts/default/full?alt=json&access_token ... 401(好)
以下是收到的authData的格式:
-auth
-provider
-uid
-expires
-google
-accessToken
-displayName
-id
-cacheduserprofile
-provider
-token
-uid