Giter Site home page Giter Site logo

esteban-uo / picasa Goto Github PK

View Code? Open in Web Editor NEW
45.0 10.0 24.0 701 KB

A simple Google Photos (formally Picasa Web Albums 2.0) client for nodejs

Home Page: http://esteban-uo.github.io/picasa/docs

JavaScript 100.00%
picasawebalbums nodejs album photos google-api picasa

picasa's Introduction

Build Status

A simple Google Photos, formally Picasa Web Albums client (2.0) for nodejs (>= 4.8.7). Includes Auth helpers.

Install

$ yarn add  picasa

or

$ npm install --save picasa

Usage

const Picasa = require('picasa')

const picasa = new Picasa()

Docs

API for Photos, Albums and Auth can be found here. Please check out also the examples dir for more detailed examples. Rename config.example.json to config.json and add your own config data.

Auth

To get an access token follow the next flow:

1.Get the Auth URL and redirect the user to it.

// Get config here API Manager > Credentials https://console.developers.google.com/home/dashboard
const config = {
  clientId     : 'yourClientId',
  redirectURI  : 'redirectURI'
}

const authURL = picasa.getAuthURL(config)

2.Google displays a consent screen to the user, asking them to authorize your application to request some of their data.

3.Google redirects a code to your redirectURI.

4.Use the code given as GET param in order to get an access token:

// Get config here API Manager > Credentials https://console.developers.google.com/home/dashboard
const config = {
  clientId     : 'yourClientId',
  redirectURI  : 'redirectURI'
  clientSecret : 'yourClientSecret'
}

picasa.getTokens(config, code).then(tokens => {
  /* use tokens.accessToken or tokens.refreshToken */
})

5.If you need to renew an expired accessToken, use the refreshToken with picasa.renewAccessToken:

const config = {
  clientId     : 'yourClientId',
  redirectURI  : 'redirectURI'
  clientSecret : 'yourClientSecret'
}

picasa.renewAccessToken(config, refreshToken).then(renewedAccessToken => {
  /* do something with renewedAccessToken */
})

Change Log

1.0.7 Functions return a Promise if callback is not provided. Use getTokens if you want to use Promises instead getAccessToken.

1.0.6 Get album, Create Album, Renew access token added. Get Photos can get all photos from an album id or all.

Contributors

Thanks to z1c0, hbakhtiyor, pauarge, wreuven, imrvelj, jlengrand

License

MIT ยฉ


Play around https://developers.google.com/oauthplayground/?code=4/usq8QmuezR3Au_0UKyj9-UXmf6Bw_ij8KFWgIziYbpM#

Picasa Docs https://developers.google.com/picasa-web/docs/2.0/developers_guide_protocol

picasa's People

Contributors

esteban-uo avatar imrvelj avatar martinlarka avatar wreuven avatar z1c0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

picasa's Issues

Uploaded Videos not processing

Hello,
let me first thank you for this great piece of software.

When i upload some videos to my picasaweb/google-photo site they don't get converted and it says: 'Your video will be ready soon' and via getPhotos() the videostatus says 'pending'

Do you experience the same anomaly?

picasa.postPhoto {statusCode: 400, body: 'Not an image.' }

I am trying:

var fs = require('fs');
fs.readFile('image.jpg', function(err, data) {
  if (err) throw err; // Fail if the file can't be read.
  console.log('writing..')
  var encodedImage = new Buffer(data, 'binary').toString('base64');
  const photoData = {
    title       : 'A title',
    summary     : 'Summary or description',
    contentType : 'image/jpeg',
    binary      : encodedImage
  };
  picasa.postPhoto(accessToken, options.albumId, photoData, (error, photo) => {
    console.log(error, photo)
  })
});

My accessToken, albumId is good. photoData is bad
How to fix? Thanks 4 great your job!!

"TypeError: Cannot read property 'executeRequest' of undefined"

In going through the OAuth flow, I'm getting "TypeError: Cannot read property 'executeRequest' of undefined" when executing picasa.getTokens(config, code).

The stack trace says this error happens on picasa.js:376:

screen shot 2018-05-07 at 10 14 21 pm

My code is running in a browser, and looks like this:

import Picasa from "picasa";
const picasa = new Picasa();

const clientId = "...apps.googleusercontent.com";
const clientSecret = "SEEEEEECRET";
const redirectURI = "http://localhost:3000/auth";

export const getAuthURL = () => {
  const config = {
    clientId,
    redirectURI
  };

  const authURL = picasa.getAuthURL(config);
  return authURL;
};

const getTokens = async code => {
  const config = {
    clientId,
    clientSecret,
    redirectURI
  };

  const tokens = await picasa.getTokens(config, code);
  return tokens;
};

// 1. send user to getAuthURL
// 2. grab the `code` from the query string at /auth and call `getTokens(code).then(tokens => {})`

What am I doing wrong?

Fetch-based version for the browser

Hi,

I added a request-method using the Fetch-API. This way the code works in the browser ๐Ÿ‘

My commit is not suited for a pull request, but it might help someone?
WietseWind@4939dd3

You can now do something like this (in a project with Vue-Webpack / browserify / ...)

window.CORSPROXY = 'https://cors-anywhere.herokuapp.com'

const Picasa = require('picasa')
const picasa = new Picasa()

window.gapi.load('auth2', () => {
    window.gapi.auth2.init(this.gSignInParams).then((gauth) => {
        if (gauth.isSignedIn.get()) {
            console.log('Logged In')

            picasa.getAlbums(window.gapi.client.getToken().access_token, null, (error, albums) => {
                if (error) return
                console.log(albums)
            })
        } else {
            console.log('Not logged in')
        }
    })
})

-- P.S. Are you on Twitter? I'd love to send you some $XRP to thank you for your awesome work :)

create album is no longer supported

what was added here 924c8e9 is no longer supported in version 3.0 of the API
https://developers.google.com/picasa-web/docs/3.0/releasenotes

 Error: UNKNOWN_ERROR
    at Request.request.(anonymous function).error [as _callback] (/myApp/node_modules/picasa/src/executeRequest.js:11:28)
    at Request.self.callback (/myApp/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/myApp/node_modules/request/request.js:1163:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/myApp/node_modules/request/request.js:1085:12)
    at IncomingMessage.g (events.js:292:16)
    at emitNone (events.js:91:20) statusCode: 400, body: 'Insert is no longer supported

maybe this can be bypassed with specifying version 2:
https://developers.google.com/picasa-web/docs/2.0/developers_guide_protocol#Versioning
but more likely this feature should be removed

Not Showing All Photos of Album

@esteban-uo - i am having a problem to list all the photos of album.I have 20000+ photos in a particular album.When i get the photos using albumid, startindex and maxresult(using 1000) parameters it works well till 11000 photos but when i try to fetch 11001 photo it gives me (status code 400 response invalid request) error.

getAuthUrl does not return a promise, and causes Typescript compilation errors

See https://github.com/esteban-uo/picasa/blob/master/src/picasa.js#L129

getAuthUrl directly returns a String, but the doc mentions a Promise.

Using the code as follows :

app.get('/login', (req, res) => {
    const authURL = picasa.getAuthURL(googleConfig);
    res.redirect(authURL);
});

raises the following Typescript compilation error:

scripts/loginAndGetGoogleToken.ts:21:18 - error TS2345: Argument of type 'Promise<any>' is not assignable to parameter of type 'string'.

21     res.redirect(authURL);
                    ~~~~~~~

Because microsoft/TypeScript#19139 is still open, there is no way to fix this without changing the documentation.

The doc for this method should be changed, and mention that it returns a String instead.

Example not working due to syntax error

I am having trouble running the example from the repo due to a syntax error:

MacBook:examples stephan$ node getAccessToken.js
/Users/stephan/Downloads/picasa-master/examples/config.js:7
  clientSecret : 'secrettoken'
  ^^^^^^^^^^^^
SyntaxError: Unexpected identifier
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/stephan/Downloads/picasa-master/examples/getAccessToken.js:4:16)
    at Module._compile (module.js:570:32)
MacBook:examples stephan$ node -v
v6.9.1
MacBook:examples stephan$ npm -v
4.0.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.