CLI application using Google APIs

Multi tool use
Multi tool use












0














I want to create an application that will download all my photos in Google Photos. I thought it should be easy with the API available.



This should be an CLI application that will run periodically from cron.
But when I looked at the Google Photos API, they use OAuth2.
The sample shows the usage of FixedCredentials:



PhotosLibrarySettings settings =
PhotosLibrarySettings.newBuilder()
.setCredentialsProvider(
FixedCredentialsProvider.create(/* Add credentials here. */))
.build();


The problem is the part where the /* Add credentials here. */ is. How can I provide my user credentials there? There are numerous classes that implement Credentials but none of them look like ones that would allow me to automate retrieval in a CLI application.



The only thing I get from Google is the client_id and client_token for my app, but how to turn that into an access/refresh token so I can use it without my interaction?



I really hope I don't need to launch a web browser to download my photos.










share|improve this question
























  • stackoverflow.com/questions/19766912/… explains how you can easily do this
    – pinoyyid
    2 hours ago
















0














I want to create an application that will download all my photos in Google Photos. I thought it should be easy with the API available.



This should be an CLI application that will run periodically from cron.
But when I looked at the Google Photos API, they use OAuth2.
The sample shows the usage of FixedCredentials:



PhotosLibrarySettings settings =
PhotosLibrarySettings.newBuilder()
.setCredentialsProvider(
FixedCredentialsProvider.create(/* Add credentials here. */))
.build();


The problem is the part where the /* Add credentials here. */ is. How can I provide my user credentials there? There are numerous classes that implement Credentials but none of them look like ones that would allow me to automate retrieval in a CLI application.



The only thing I get from Google is the client_id and client_token for my app, but how to turn that into an access/refresh token so I can use it without my interaction?



I really hope I don't need to launch a web browser to download my photos.










share|improve this question
























  • stackoverflow.com/questions/19766912/… explains how you can easily do this
    – pinoyyid
    2 hours ago














0












0








0







I want to create an application that will download all my photos in Google Photos. I thought it should be easy with the API available.



This should be an CLI application that will run periodically from cron.
But when I looked at the Google Photos API, they use OAuth2.
The sample shows the usage of FixedCredentials:



PhotosLibrarySettings settings =
PhotosLibrarySettings.newBuilder()
.setCredentialsProvider(
FixedCredentialsProvider.create(/* Add credentials here. */))
.build();


The problem is the part where the /* Add credentials here. */ is. How can I provide my user credentials there? There are numerous classes that implement Credentials but none of them look like ones that would allow me to automate retrieval in a CLI application.



The only thing I get from Google is the client_id and client_token for my app, but how to turn that into an access/refresh token so I can use it without my interaction?



I really hope I don't need to launch a web browser to download my photos.










share|improve this question















I want to create an application that will download all my photos in Google Photos. I thought it should be easy with the API available.



This should be an CLI application that will run periodically from cron.
But when I looked at the Google Photos API, they use OAuth2.
The sample shows the usage of FixedCredentials:



PhotosLibrarySettings settings =
PhotosLibrarySettings.newBuilder()
.setCredentialsProvider(
FixedCredentialsProvider.create(/* Add credentials here. */))
.build();


The problem is the part where the /* Add credentials here. */ is. How can I provide my user credentials there? There are numerous classes that implement Credentials but none of them look like ones that would allow me to automate retrieval in a CLI application.



The only thing I get from Google is the client_id and client_token for my app, but how to turn that into an access/refresh token so I can use it without my interaction?



I really hope I don't need to launch a web browser to download my photos.







java oauth-2.0 google-api google-oauth google-photos-api






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 12 hours ago

























asked 15 hours ago









Krzysztof Krasoń

15.3k95782




15.3k95782












  • stackoverflow.com/questions/19766912/… explains how you can easily do this
    – pinoyyid
    2 hours ago


















  • stackoverflow.com/questions/19766912/… explains how you can easily do this
    – pinoyyid
    2 hours ago
















stackoverflow.com/questions/19766912/… explains how you can easily do this
– pinoyyid
2 hours ago




stackoverflow.com/questions/19766912/… explains how you can easily do this
– pinoyyid
2 hours ago












1 Answer
1






active

oldest

votes


















1














The Google Photos Library API only accepts OAuth User Credentials. This means that users are required to complete the Google OAuth Flow, which means browser based Authorization.




Note: The Library API does not support service accounts. Your
application must use the other OAuth 2.0 flows available such as OAuth
2.0 for web server applications or OAuth 2.0 for mobile and desktop apps.



Your application must use OAuth 2.0 to authorize requests. No other
authorization protocols are supported. If your application uses Google
Sign-In, some aspects of authorization are handled for you.




This links details these requirements:



Authentication and authorization scopes






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53942381%2fcli-application-using-google-apis%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    The Google Photos Library API only accepts OAuth User Credentials. This means that users are required to complete the Google OAuth Flow, which means browser based Authorization.




    Note: The Library API does not support service accounts. Your
    application must use the other OAuth 2.0 flows available such as OAuth
    2.0 for web server applications or OAuth 2.0 for mobile and desktop apps.



    Your application must use OAuth 2.0 to authorize requests. No other
    authorization protocols are supported. If your application uses Google
    Sign-In, some aspects of authorization are handled for you.




    This links details these requirements:



    Authentication and authorization scopes






    share|improve this answer


























      1














      The Google Photos Library API only accepts OAuth User Credentials. This means that users are required to complete the Google OAuth Flow, which means browser based Authorization.




      Note: The Library API does not support service accounts. Your
      application must use the other OAuth 2.0 flows available such as OAuth
      2.0 for web server applications or OAuth 2.0 for mobile and desktop apps.



      Your application must use OAuth 2.0 to authorize requests. No other
      authorization protocols are supported. If your application uses Google
      Sign-In, some aspects of authorization are handled for you.




      This links details these requirements:



      Authentication and authorization scopes






      share|improve this answer
























        1












        1








        1






        The Google Photos Library API only accepts OAuth User Credentials. This means that users are required to complete the Google OAuth Flow, which means browser based Authorization.




        Note: The Library API does not support service accounts. Your
        application must use the other OAuth 2.0 flows available such as OAuth
        2.0 for web server applications or OAuth 2.0 for mobile and desktop apps.



        Your application must use OAuth 2.0 to authorize requests. No other
        authorization protocols are supported. If your application uses Google
        Sign-In, some aspects of authorization are handled for you.




        This links details these requirements:



        Authentication and authorization scopes






        share|improve this answer












        The Google Photos Library API only accepts OAuth User Credentials. This means that users are required to complete the Google OAuth Flow, which means browser based Authorization.




        Note: The Library API does not support service accounts. Your
        application must use the other OAuth 2.0 flows available such as OAuth
        2.0 for web server applications or OAuth 2.0 for mobile and desktop apps.



        Your application must use OAuth 2.0 to authorize requests. No other
        authorization protocols are supported. If your application uses Google
        Sign-In, some aspects of authorization are handled for you.




        This links details these requirements:



        Authentication and authorization scopes







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 14 hours ago









        John Hanley

        13.5k2528




        13.5k2528






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53942381%2fcli-application-using-google-apis%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            cZ 9rZ c p hNL6jIV
            6Tz2yosd2M,kS4QtwDBj,shDgrOi7 kW qmj,MMK

            Popular posts from this blog

            Monofisismo

            compose and upload a new article using a custom form

            “attempting to read past stream EOM” using Sybase.AdoNet4.AseClient