From: Andrew Grimberg Date: Mon, 9 Oct 2023 15:49:31 +0000 (-0700) Subject: Refactor: Add annoations to lftools.oauth2_helper X-Git-Tag: v0.37.7~7 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F36%2F72236%2F1;p=releng%2Flftools.git Refactor: Add annoations to lftools.oauth2_helper Issue: RELENG-4933 Signed-off-by: Andrew Grimberg Change-Id: I5d80203fa91196de29e77c55721150668545aeee --- diff --git a/lftools/oauth2_helper.py b/lftools/oauth2_helper.py index 13561495..ef73ecd6 100644 --- a/lftools/oauth2_helper.py +++ b/lftools/oauth2_helper.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: EPL-1.0 ############################################################################## -# Copyright (c) 2019 The Linux Foundation and others. +# Copyright (c) 2019, 2023 The Linux Foundation and others. # # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 @@ -8,8 +8,10 @@ # http://www.eclipse.org/legal/epl-v10.html ############################################################################## """Helper script to get access_token for lfid api.""" +from __future__ import annotations import logging +from typing import Tuple import httplib2 from oauth2client import client @@ -17,16 +19,16 @@ from oauth2client import client from lftools import config -def oauth_helper(): +def oauth_helper() -> Tuple[str, str]: """Helper script to get access_token for lfid api.""" logging.getLogger("oauth2client").setLevel(logging.ERROR) - client_id = config.get_setting("lfid", "clientid") - client_secret = config.get_setting("lfid", "client_secret") - refresh_token = config.get_setting("lfid", "refresh_token") - token_uri = config.get_setting("lfid", "token_uri") - url = config.get_setting("lfid", "url") + client_id: str = config.get_setting("lfid", "clientid") + client_secret: str = config.get_setting("lfid", "client_secret") + refresh_token: str = config.get_setting("lfid", "refresh_token") + token_uri: str = config.get_setting("lfid", "token_uri") + url: str = config.get_setting("lfid", "url") - credentials = client.OAuth2Credentials( + credentials: client.Oauth2Credentials = client.OAuth2Credentials( access_token=None, # set access_token to None since we use a refresh token client_id=client_id, client_secret=client_secret, @@ -36,5 +38,5 @@ def oauth_helper(): user_agent=None, ) credentials.refresh(httplib2.Http()) - access_token = credentials.access_token + access_token: str = credentials.access_token return access_token, url