FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fixing get Google default credentials method by gabrielgbim · Pull Request #21 · kubernetes-client/python-base · GitHub

This repository was archived by the owner on Mar 13, 2022. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
15 changes: 12 additions & 3 deletions config/kube_config.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
import yaml
from google.oauth2.credentials import Credentials

import google.auth
import google.auth.transport.requests
import requests

from kubernetes.client import ApiClient, ConfigurationObject, configuration

from .config_exception import ConfigException
Expand Down Expand Up @@ -117,12 +121,17 @@ def __init__(self, config_dict, active_context=None,
self._cluster = None
self.set_active_context(active_context)
self._config_base_path = config_base_path

def _refresh_credentials():
credentials, project_id = google.auth.default()
request = google.auth.transport.requests.Request()
credentials.refresh(request)
return credentials.token

if get_google_credentials:
self._get_google_credentials = get_google_credentials
else:
self._get_google_credentials = lambda: (
GoogleCredentials.get_application_default()
.get_access_token().access_token)
self._get_google_credentials = _refresh_credentials
self._client_configuration = client_configuration

def set_active_context(self, context_name=None):
Expand Down

Back | FazBrowse Home | New Git URL