Skip to content

Unable to access private APIs #1225

Description

@habibutsu

There is no possibility to use earthengine api with default behavior (static_discovery=True), because corresponded file is missed in discovery_cache.

In addition this changes broke earthengine-api, see issues/157

Activity

  1. self-assigned this
    on Mar 4, 2021
  2. busunkim96 commented on Mar 5, 2021

    @busunkim96
    Contributor

    Hi,

    I think from the perspective of this library things are working as intended. static_discovery=True can only be used with APIs listed in the public directory of Google APIs: https://www.googleapis.com/discovery/v1/apis.

    If an API is outside that list (API is private and/or not listed in the directory), there are two options:

    1. Use discovery.build_from_document() with a copy of a discovery doc JSON for the API.

    It looks like https://github.com/google/earthengine-api/blob/114dcad4bdd2edd7cf604c39e33019baab15436d/python/ee/_cloud_api_utils.py#L156-L179 does this, but only for tests.

    Pros:

    • Library will not change unexpectedly.
    • No dependency on the live discovery document being available.

    Cons:

    • Need to update the JSON file manually.

    2. Use discovery.build() and pass both discoveryServiceUrl and static_discovery=False.

    from googleapiclient import discovery
    
    client = discovery.build(
        "commentanalyzer",
        "v1alpha1",
        discoveryServiceUrl="https://commentanalyzer.googleapis.com/$discovery/rest?version=v1alpha1",
        static_discovery=False,
    )

    This results in behavior equivalent to 1.x of this library.

    Pros:

    • Library always matches the latest version of the API.

    Cons:

    • If the discovery doc is unavailable for some period of time, you cannot use the Python library.
    • The discovery doc may change in unexpected ways, resulting in different results from running the same code with the same dependencies multiple times.

    @parthea Would you mind adding some information to the docs clarifying which APIs are available with static_discovery=True?

  3. parthea commented on Mar 5, 2021

    @parthea
    Contributor

    Will do. In addition, there is an internal inquiry open for making the EarthEngine API discovery document public. Googlers see b/179047744

  4. busunkim96 commented on Mar 5, 2021

    @busunkim96
    Contributor

    Googlers,

    If you're an API owner and your users are broken by v2 please make sure:

    1. The discovery document is public
    2. The API is listed in the discovery directory.

    As an added bonus you will get client libraries in the other languages with Discovery-based generators. :)

  5. Ark-kun commented on Mar 8, 2021

    @Ark-kun

    If you're an API owner and your users are broken by v2 please make sure:

    1. The discovery document is public

    What can we do for private APIs?

  6. busunkim96 commented on Mar 8, 2021

    @busunkim96
    Contributor

    Hi @Ark-kun,

    Please see #1225 (comment).

    Right now, you would do something like this to call a private API:

    from googleapiclient import discovery
    
    client = discovery.build(
        "myapi",
        "v1alpha1",
        discoveryServiceUrl="https://myapi.googleapis.com/$discovery/rest?version=v1alpha1",
        static_discovery=False,
    )

    @parthea and I were discussing automatically setting static_discovery=False if discoveryServiceUrl is passed. With that change folks would do something like this:

    from googleapiclient import discovery
    
    client = discovery.build(
        "myapi",
        "v1alpha1",
        discoveryServiceUrl="https://myapi.googleapis.com/$discovery/rest?version=v1alpha1",
    )
  7. added
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Mar 9, 2021
  8. wyk9787 commented on Mar 11, 2021

    @wyk9787

    @busunkim96 Is there an ETA on when we can call private API without specifying static_discovery=False (i.e. entirely backward compatible for client library 2.0 in terms of building the discovery client) ?

  9. changed the title [-]Missed earthengine.v1alpha.json[/-] [+]Unable to access private APIs[/+] on Mar 12, 2021
  10. busunkim96 commented on Mar 12, 2021

    @busunkim96
    Contributor

    @wyk9787 I think by the end of this month. It should be a relatively small change in discovery.build().

  11. removed
    type: docsImprovement to the documentation for an API.
    on Mar 12, 2021
  12. added a commit that references this issue on Mar 15, 2021
    a6f1706
  13. added a commit that references this issue on Mar 19, 2021
    3b4f2e2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions