Ich versuche, an meinem Heimprojekt zu arbeiten, wo ich mich mit Google Services wie Google Mail, Sheets und Drive wende. Dienste, die nicht Google Cloud per se sind.
Traceback (most recent call last):
File "c:\Users\48513\A-i-tomations\Accounting\accounting-scripts\gmail_service.py", line 25, in
test(creds)
File "c:\Users\48513\A-i-tomations\Accounting\accounting-scripts\gmail_service.py", line 13, in test
results = service.users().labels().list(userId="me").execute()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\googleapiclient\http.py", line 923, in execute
resp, content = _retry_request(
^^^^^^^^^^^^^^^
File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\googleapiclient\http.py", line 191, in _retry_request
resp, content = http.request(uri, method, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\google_auth_httplib2.py", line 209, in request
self.credentials.before_request(self._request, method, uri, request_headers)
File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\google\auth\credentials.py", line 239, in before_request
self._blocking_refresh(request)
File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\google\auth\credentials.py", line 202, in _blocking_refresh
self.refresh(request)
File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\google\oauth2\credentials.py", line 409, in refresh
) = reauth.refresh_grant(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\google\oauth2\reauth.py", line 349, in refresh_grant
raise exceptions.RefreshError(
google.auth.exceptions.RefreshError: Reauthentication is needed. Please run `gcloud auth application-default login` to reauthenticate.
< /code>
Aber zuerst gehe ich davon aus, dass es nicht die OAuth -Authentifizierung verwenden sollte. Mit Anmeldeinformationen von Anmeldeinformationen.json.CLIENTSECRETS_LOCATION = './credentials/credentials.json'
TOKEN_LOCATION = './credentials/token.json'
SCOPES = ['https://www.googleapis.com/auth/gmail.readonly']
def readCredentials():
creds = None
# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists(TOKEN_LOCATION):
print("Loading existing credentials from token.json")
creds = Credentials.from_authorized_user_file(TOKEN_LOCATION, SCOPES)
# If there are no (valid) credentials available, let the user log in.
print("Checking credentials validity...")
if not creds or not creds.valid:
print("Credentials are not valid or expired.")
if creds and creds.expired and creds.refresh_token:
print("Refreshing expired credentials...")
creds.refresh(Request())
else:
print("No valid credentials available, initiating login flow.")
flow = InstalledAppFlow.from_client_secrets_file(CLIENTSECRETS_LOCATION, SCOPES)
creds = flow.run_local_server(port=8080)
# Save the credentials for the next run
with open(TOKEN_LOCATION, "w") as token:
token.write(creds.to_json())
< /code>
und der Code, der Google Mail -API aufgerufen hat: < /p>
def test(creds: Credentials):
# Call the Gmail API
service: Resource = build("gmail", "v1", credentials=creds)
results = service.users().labels().list(userId="me").execute()
labels = results.get("labels", [])
if not labels:
print("No labels found.")
return
print("Labels:")
for label in labels:
print(label["name"])
if __name__ == "__main__":
creds = readCredentials()
test(creds)
Ich habe versucht, mit der Fehlermeldung zu gehen, und versuchte, GCLOUD-Authaut-Anwendungs-Default-Login mit meinem persönlichen Konto nicht verwaltet zu machen, aber dann habe ich diesen Fehler:
Traceback (most recent call last):
File "c:\Users\48513\A-i-tomations\Accounting\accounting-scripts\gmail_service.py", line 25, in
test(creds)
File "c:\Users\48513\A-i-tomations\Accounting\accounting-scripts\gmail_service.py", line 13, in test
results = service.users().labels().list(userId="me").execute()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\googleapiclient\http.py", line 938, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError:
Ich versuche, an meinem Heimprojekt zu arbeiten, wo ich mich mit Google Services wie Google Mail, Sheets und Drive wende. Dienste, die nicht Google Cloud per se sind.[code]Traceback (most recent call last): File "c:\Users\48513\A-i-tomations\Accounting\accounting-scripts\gmail_service.py", line 25, in test(creds) File "c:\Users\48513\A-i-tomations\Accounting\accounting-scripts\gmail_service.py", line 13, in test results = service.users().labels().list(userId="me").execute() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapper return wrapped(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\googleapiclient\http.py", line 923, in execute resp, content = _retry_request( ^^^^^^^^^^^^^^^ File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\googleapiclient\http.py", line 191, in _retry_request resp, content = http.request(uri, method, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\google_auth_httplib2.py", line 209, in request self.credentials.before_request(self._request, method, uri, request_headers) File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\google\auth\credentials.py", line 239, in before_request self._blocking_refresh(request) File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\google\auth\credentials.py", line 202, in _blocking_refresh self.refresh(request) File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\google\oauth2\credentials.py", line 409, in refresh ) = reauth.refresh_grant( ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\google\oauth2\reauth.py", line 349, in refresh_grant raise exceptions.RefreshError( google.auth.exceptions.RefreshError: Reauthentication is needed. Please run `gcloud auth application-default login` to reauthenticate. < /code> Aber zuerst gehe ich davon aus, dass es nicht die OAuth -Authentifizierung verwenden sollte. Mit Anmeldeinformationen von Anmeldeinformationen.json.CLIENTSECRETS_LOCATION = './credentials/credentials.json' TOKEN_LOCATION = './credentials/token.json' SCOPES = ['https://www.googleapis.com/auth/gmail.readonly']
def readCredentials(): creds = None # The file token.json stores the user's access and refresh tokens, and is # created automatically when the authorization flow completes for the first # time. if os.path.exists(TOKEN_LOCATION): print("Loading existing credentials from token.json") creds = Credentials.from_authorized_user_file(TOKEN_LOCATION, SCOPES) # If there are no (valid) credentials available, let the user log in. print("Checking credentials validity...") if not creds or not creds.valid: print("Credentials are not valid or expired.") if creds and creds.expired and creds.refresh_token: print("Refreshing expired credentials...") creds.refresh(Request()) else: print("No valid credentials available, initiating login flow.") flow = InstalledAppFlow.from_client_secrets_file(CLIENTSECRETS_LOCATION, SCOPES) creds = flow.run_local_server(port=8080) # Save the credentials for the next run with open(TOKEN_LOCATION, "w") as token: token.write(creds.to_json()) < /code> und der Code, der Google Mail -API aufgerufen hat: < /p> def test(creds: Credentials): # Call the Gmail API service: Resource = build("gmail", "v1", credentials=creds) results = service.users().labels().list(userId="me").execute() labels = results.get("labels", [])
if not labels: print("No labels found.") return print("Labels:") for label in labels: print(label["name"])
if __name__ == "__main__": creds = readCredentials() test(creds) [/code] Ich habe versucht, mit der Fehlermeldung zu gehen, und versuchte, GCLOUD-Authaut-Anwendungs-Default-Login mit meinem persönlichen Konto nicht verwaltet zu machen, aber dann habe ich diesen Fehler: [code]Traceback (most recent call last): File "c:\Users\48513\A-i-tomations\Accounting\accounting-scripts\gmail_service.py", line 25, in test(creds) File "c:\Users\48513\A-i-tomations\Accounting\accounting-scripts\gmail_service.py", line 13, in test results = service.users().labels().list(userId="me").execute() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapper return wrapped(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\48513\A-i-tomations\Accounting\accounting-scripts\Lib\site-packages\googleapiclient\http.py", line 938, in execute raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: [/code]
Ich arbeite derzeit an einer C# .NET -Anwendung, mit der das Google -Administrator -SDK nutzt, um Verwaltungsaufgaben in unserer Organisation zu verwalten. Im Rahmen dieser Implementierung benötige...
Beschreibung :
Ich erstelle eine Version des Campfire Story -Spiels, bei dem jede Person die Geschichte hinzufügt, mit einer Übergangsanweisung für den nächsten Spieler endet und die Wende zum...
Ich arbeite daran, Google OAuth in meine .NET -API zu integrieren, um die Authentifizierung sowohl für eine Web -App als auch für eine mobile App (z. B. mit Flutter erstellt) zu unterstützen. Ich bin...
Titel: Intermittierender SSO-Fehler, der neu gestartet wird-Mögliches Konfigurationsproblem? Nach einiger Zeit beginnt eine Untergruppe von Benutzern einen Fehler. Das Neustart des SSO -Dienstes löst...
Ich versuche, die Google -Bibliothek für BQ -Integration zu verwenden. Ich verwende Maven, um Abhängigkeiten und Java 17 für Kompilierung und Laufzeit zu verwalten. Versionsverwaltung, zwei...