Skip to content

Commit 8312d29

Browse files
committed
Fix for pubsub scope error.
1 parent f8e499a commit 8312d29

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pubsub/google/cloud/pubsub/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import os
1818

19+
import google.auth.credentials
1920
from google.cloud.client import JSONClient
2021
from google.cloud.environment_vars import DISABLE_GRPC
2122
from google.cloud.pubsub._http import Connection
@@ -42,6 +43,9 @@
4243
_DISABLE_GAX = os.getenv(DISABLE_GRPC, False)
4344
_USE_GAX = _HAVE_GAX and not _DISABLE_GAX
4445

46+
_SCOPES = ('https://www.googleapis.com/auth/pubsub',
47+
'https://www.googleapis.com/auth/cloud-platform')
48+
4549

4650
class Client(JSONClient):
4751
"""Client to bundle configuration needed for API requests.
@@ -79,6 +83,8 @@ def __init__(self, project=None, credentials=None,
7983
http=None, use_gax=None):
8084
super(Client, self).__init__(
8185
project=project, credentials=credentials, http=http)
86+
self._credentials = google.auth.credentials.with_scopes_if_required(
87+
self._credentials, _SCOPES)
8288
self._connection = Connection(
8389
credentials=self._credentials, http=self._http)
8490
if use_gax is None:

0 commit comments

Comments
 (0)