question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to access private APIs

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
busunkim96commented, Mar 8, 2021

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?

2reactions
busunkim96commented, Mar 8, 2021

Hi @Ark-kun,

Please see https://github.com/googleapis/google-api-python-client/issues/1225#issuecomment-791045487.

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",
)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve connection issues with API Gateway private ...
1. Verify that an API Gateway execute-api VPC endpoint exists in the VPC. · 2. Verify that the client invoking the private API...
Read more >
amazon web services - Unable to Access AWS Private Api
I have created an internal private api and want to access it from ec2 instance. For this, I have create an endpoint and...
Read more >
Troubleshooting API Gateway Private API
This article give details on various reasons and steps to troubleshooting API Gateway Private APIs for access related issues.
Read more >
How to invoke a private API - Amazon API Gateway
Private APIs are accessible only from within your VPCs, and the resource policies must allow access from the VPCs and VPC endpoints you...
Read more >
AWS Private API GW & how VPCEs do not extend out of VPC
You need to have a private AWS API gateway running. If you have whitelisted the VPCIE ID in the API GW resource policy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found