Python 2.7 has reached end of support
and will be
deprecated
on January 31, 2026. After deprecation, you won't be able to deploy Python 2.7
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing Python
2.7 applications will continue to run and receive traffic after their
deprecation date. We recommend that
you
migrate to the latest supported version of Python.
Stay organized with collections
Save and categorize content based on your preferences.
google.appengine.api.oauth.oauth_api module
Summary
OAuth API.
A service that enables App Engine apps to validate OAuth requests.
- Classes defined here:
-
Error: base exception type
NotAllowedError: OAuthService exception
OAuthRequestError: OAuthService exception
InvalidOAuthParametersError: OAuthService exception
InvalidOAuthTokenError: OAuthService exception
OAuthServiceFailureError: OAuthService exception
Contents
- exception google.appengine.api.oauth.oauth_api.Errorsource
-
Bases: exceptions.Exception
Base error class for this module.
- exception google.appengine.api.oauth.oauth_api.InvalidOAuthParametersErrorsource
-
Bases: google.appengine.api.oauth.oauth_api.OAuthRequestError
Raised if the request was a malformed OAuth request.
For example, the request may have omitted a required parameter, contained
an invalid signature, or was made by an unknown consumer.
- google.appengine.api.oauth.oauth_api.get_authorized_scopes(scope)source
Returns authorized scopes from input scopes.
Parametersscope – The custom OAuth scope or an iterable of scopes at least one of
which is accepted.
ReturnsA list of authorized OAuth2 scopes
Return typelist
Raises
- google.appengine.api.oauth.oauth_api.get_client_id(_scope)source
Returns the value of OAuth2 Client ID from an OAuth2 request.
Parameters_scope – The custom OAuth scope or an iterable of scopes at least one of
which is accepted.
ReturnsThe value of Client ID.
Return typestring
Raises
- google.appengine.api.oauth.oauth_api.get_current_user(_scope=None)source
Returns the User on whose behalf the request was made.
Parameters_scope – The custom OAuth scope or an iterable of scopes at least one of
which is accepted.
ReturnsUser
Raises
- google.appengine.api.oauth.oauth_api.get_oauth_consumer_key()source
-
OAuth1 authentication is deprecated and turned down.
- google.appengine.api.oauth.oauth_api.is_current_user_admin(_scope=None)source
Returns true if the User on whose behalf the request was made is an admin.
Parameters_scope – The custom OAuth scope or an iterable of scopes at least one of
which is accepted.
Returnsboolean
Raises
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["\u003cp\u003eThe \u003ccode\u003egoogle.appengine.api.oauth.oauth_api\u003c/code\u003e module provides a service for App Engine applications to validate OAuth requests, managing the authentication and authorization process.\u003c/p\u003e\n"],["\u003cp\u003eThis module defines several exception classes, including \u003ccode\u003eError\u003c/code\u003e, \u003ccode\u003eOAuthRequestError\u003c/code\u003e, \u003ccode\u003eInvalidOAuthParametersError\u003c/code\u003e, \u003ccode\u003eInvalidOAuthTokenError\u003c/code\u003e, \u003ccode\u003eNotAllowedError\u003c/code\u003e, and \u003ccode\u003eOAuthServiceFailureError\u003c/code\u003e, which represent different types of errors that can occur during OAuth request handling.\u003c/p\u003e\n"],["\u003cp\u003eIt includes functions like \u003ccode\u003eget_authorized_scopes\u003c/code\u003e, \u003ccode\u003eget_client_id\u003c/code\u003e, \u003ccode\u003eget_current_user\u003c/code\u003e, and \u003ccode\u003eis_current_user_admin\u003c/code\u003e that allow applications to retrieve information about the OAuth request, such as authorized scopes, the client ID, the current user, and whether the user is an admin.\u003c/p\u003e\n"],["\u003cp\u003eThe module's functionality is primarily focused on OAuth2 requests, as OAuth1 authentication has been deprecated and turned down.\u003c/p\u003e\n"],["\u003cp\u003eThe core functionality revolves around validating OAuth requests and handling various associated exceptions, such as invalid parameters, invalid tokens, or service failures.\u003c/p\u003e\n"]]],[],null,["# google.appengine.api.oauth.oauth_api module\n===========================================\n\nSummary\n-------\n\nOAuth API.\n\nA service that enables App Engine apps to validate OAuth requests.\n\nClasses defined here:\n\n: Error: base exception type\n NotAllowedError: OAuthService exception\n OAuthRequestError: OAuthService exception\n InvalidOAuthParametersError: OAuthService exception\n InvalidOAuthTokenError: OAuthService exception\n OAuthServiceFailureError: OAuthService exception\n\nContents\n--------\n\n*exception* google.appengine.api.oauth.oauth_api.Error[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/oauth/oauth_api#Error)\n\n: Bases: exceptions.Exception\n\nBase error class for this module. \n\n*exception* google.appengine.api.oauth.oauth_api.InvalidOAuthParametersError[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/oauth/oauth_api#InvalidOAuthParametersError)\n\n: Bases: [google.appengine.api.oauth.oauth_api.OAuthRequestError](#google.appengine.api.oauth.oauth_api.OAuthRequestError)\n\n Raised if the request was a malformed OAuth request.\n\n For example, the request may have omitted a required parameter, contained\nan invalid signature, or was made by an unknown consumer. \n\n*exception* google.appengine.api.oauth.oauth_api.InvalidOAuthTokenError[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/oauth/oauth_api#InvalidOAuthTokenError)\n\n: Bases: [google.appengine.api.oauth.oauth_api.OAuthRequestError](#google.appengine.api.oauth.oauth_api.OAuthRequestError)\n\n Raised if the request contained an invalid token.\n\nFor example, the token may have been revoked by the user. \n\n*exception* google.appengine.api.oauth.oauth_api.NotAllowedError[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/oauth/oauth_api#NotAllowedError)\n\n: Bases: [google.appengine.api.oauth.oauth_api.OAuthRequestError](#google.appengine.api.oauth.oauth_api.OAuthRequestError)\n\nRaised if the requested URL does not permit OAuth authentication. \n\n*exception* google.appengine.api.oauth.oauth_api.OAuthRequestError[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/oauth/oauth_api#OAuthRequestError)\n\n: Bases: [google.appengine.api.oauth.oauth_api.Error](#google.appengine.api.oauth.oauth_api.Error)\n\nBase error type for invalid OAuth requests. \n\n*exception* google.appengine.api.oauth.oauth_api.OAuthServiceFailureError[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/oauth/oauth_api#OAuthServiceFailureError)\n\n: Bases: [google.appengine.api.oauth.oauth_api.Error](#google.appengine.api.oauth.oauth_api.Error)\n\nRaised if there was a problem communicating with the OAuth service. \n\ngoogle.appengine.api.oauth.oauth_api.get_authorized_scopes(scope)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/oauth/oauth_api#get_authorized_scopes)\n\n: Returns authorized scopes from input scopes.\n\n Parameters\n\n scope -- The custom OAuth scope or an iterable of scopes at least one of\n which is accepted.\n Returns\n\n A list of authorized OAuth2 scopes\n Return type\n\n list\n Raises\n\n - [OAuthRequestError](#google.appengine.api.oauth.oauth_api.OAuthRequestError) -- The request was not a valid OAuth2 request.\n\n - [OAuthServiceFailureError](#google.appengine.api.oauth.oauth_api.OAuthServiceFailureError) -- An unknown error occurred\n\ngoogle.appengine.api.oauth.oauth_api.get_client_id(_scope)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/oauth/oauth_api#get_client_id)\n\n: Returns the value of OAuth2 Client ID from an OAuth2 request.\n\n Parameters\n\n _scope -- The custom OAuth scope or an iterable of scopes at least one of\n which is accepted.\n Returns\n\n The value of Client ID.\n Return type\n\n string\n Raises\n\n - [OAuthRequestError](#google.appengine.api.oauth.oauth_api.OAuthRequestError) -- The request was not a valid OAuth2 request.\n\n - [OAuthServiceFailureError](#google.appengine.api.oauth.oauth_api.OAuthServiceFailureError) -- An unknown error occurred.\n\ngoogle.appengine.api.oauth.oauth_api.get_current_user(_scope=None)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/oauth/oauth_api#get_current_user)\n\n: Returns the User on whose behalf the request was made.\n\n Parameters\n\n _scope -- The custom OAuth scope or an iterable of scopes at least one of\n which is accepted.\n Returns\n\n User\n Raises\n\n - [OAuthRequestError](#google.appengine.api.oauth.oauth_api.OAuthRequestError) -- The request was not a valid OAuth request.\n\n - [OAuthServiceFailureError](#google.appengine.api.oauth.oauth_api.OAuthServiceFailureError) -- An unknown error occurred.\n\ngoogle.appengine.api.oauth.oauth_api.get_oauth_consumer_key()[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/oauth/oauth_api#get_oauth_consumer_key)\n\n: OAuth1 authentication is deprecated and turned down.\n\ngoogle.appengine.api.oauth.oauth_api.is_current_user_admin(_scope=None)[source](/appengine/docs/legacy/standard/python/refdocs/modules/google/appengine/api/oauth/oauth_api#is_current_user_admin)\n\n: Returns true if the User on whose behalf the request was made is an admin.\n\n Parameters\n\n _scope -- The custom OAuth scope or an iterable of scopes at least one of\n which is accepted.\n Returns\n\n boolean\n Raises\n\n - [OAuthRequestError](#google.appengine.api.oauth.oauth_api.OAuthRequestError) -- The request was not a valid OAuth request.\n\n - [OAuthServiceFailureError](#google.appengine.api.oauth.oauth_api.OAuthServiceFailureError) -- An unknown error occurred."]]