omarryhan / aiogoogle

Async Google API Client + Async Google Auth
https://aiogoogle.readthedocs.io/en/latest/
MIT License
192 stars 47 forks source link

Places v1 API not supported #144

Closed gregbrowndev closed 4 weeks ago

gregbrowndev commented 3 months ago

Example

from aiogoogle import Aiogoogle
from aiogoogle.auth import ApiKey

async def main() -> None:
    google_places_key = "..."

    async with Aiogoogle(
        api_key=ApiKey(google_places_key)
    ) as aiogoogle:

        # Finds service: "place" "v1"
        results = await aiogoogle.list_api("places")
        print(results)

        # Throws error! 
        results = await aiogoogle.discover('places', 'v1')
        print(results)

if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Output:

{'discoveryVersion': 'v1',
 'items': [{'description': '',
            'discoveryRestUrl': 'https://places.googleapis.com/$discovery/rest?version=v1',
            'documentationLink': 'https://mapsplatform.google.com/maps-products/#places-section',
            'icons': {'x16': 'https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png',
                      'x32': 'https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png'},
            'id': 'places:v1',
            'kind': 'discovery#directoryItem',
            'name': 'places',
            'preferred': True,
            'title': 'Places API (New)',
            'version': 'v1'}],
 'kind': 'discovery#directoryList'}

Not Found

Content:
{'code': 404,
 'message': 'Requested entity was not found.',
 'status': 'NOT_FOUND'}

Request URL:
https://www.googleapis.com/discovery/v1/apis/places/v1/rest
omarryhan commented 3 months ago

Hi @gregbrowndev , in your .discover() call, can you try passing disco_doc_ver=2? As far as I remember, some APIs only work with this param passed.

omarryhan commented 4 weeks ago

Please reopen if my recommendation above doesn't work, thanks!