Skip to content
Snippets Groups Projects
Select Git revision
  • 353ea222aabab40ecabbc9294e579c2c1db2a2ca
  • master default protected
  • bugfix/fix-return-var-in-find
  • feature/upgrade2
  • v1.10.0
  • v1.8.2
  • v1.8.1
  • v1.8.0
  • 1.7.3
  • v1.7.1
  • v1.6.1
  • v1.6.0
  • v1.5.0
  • v1.4.1
  • v1.3.0
  • v1.2.2
  • v1.2.1
  • v1.2.0
  • v1.0.1
  • v1.0.0
  • v0.0.23
  • v0.0.17
  • v0.0.10
  • v0.0.9
24 results

environments.py

Blame
  • collections_auth_client.py 1.22 KiB
    import logging
    
    import grpc
    from oauthlib.oauth2 import BackendApplicationClient
    
    from perxis.auth import OAuth2Plugin
    from perxis.collections import collections_pb2, collections_pb2_grpc
    
    
    def main():
        client_id = 'YGPQSAUPgco4iTQxNejtXDjFVwPmYT3n'
        client_secret = '_d6F-VlQGmcsU25AXIoCU4EU3v56-28P6jwUHkutg_hSPseConphyLs3F-Buuq1h'
        token_url = 'https://adwz.auth0.com/oauth/token'
        audience = 'some'
    
        oauth2_plugin = OAuth2Plugin(
            client=BackendApplicationClient(client_id=client_id),
            client_secret=client_secret,
            token_url=token_url,
            audience=audience
        )
    
        call_credentials = grpc.metadata_call_credentials(oauth2_plugin, name='auth')
        channel_credentials = grpc.ssl_channel_credentials()
        composite_credentials = grpc.composite_channel_credentials(
                channel_credentials, call_credentials
        )
        with grpc.secure_channel('envoy.perxis.pt.perx.ru:443', composite_credentials) as channel:
            stub = collections_pb2_grpc.CollectionsStub(channel)
            collections = stub.List(collections_pb2.ListRequest(space_id="c2qcp9cuaccmpj8lmom0", env_id="master"))
            print(collections)
    
    
    if __name__ == '__main__':
        logging.basicConfig(level=logging.INFO)
        main()