Begin support for updated gcloud
Project: http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/commit/34c685db Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/tree/34c685db Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/diff/34c685db Branch: refs/heads/master Commit: 34c685db1a5041f6f7bbbed8901f6210ee4e1b03 Parents: 444de87 Author: BroganD1993 <darrenbro...@hotmail.com> Authored: Thu Jul 24 21:08:23 2014 +0100 Committer: BroganD1993 <darrenbro...@hotmail.com> Committed: Thu Jul 24 21:08:23 2014 +0100 ---------------------------------------------------------------------- .gitignore | 2 +- gstack/oauth2provider.py | 1 - pyoauth2/provider.py | 15 ++++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/blob/34c685db/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index c5815a1..e0b486f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *.db - +*.xml *.py[cod] *~ *.db http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/blob/34c685db/gstack/oauth2provider.py ---------------------------------------------------------------------- diff --git a/gstack/oauth2provider.py b/gstack/oauth2provider.py index ce08aa1..9a64e87 100644 --- a/gstack/oauth2provider.py +++ b/gstack/oauth2provider.py @@ -88,7 +88,6 @@ class CloudstackAuthorizationProvider(AuthorizationProvider): if existing_access_token is not None: existing_access_token.access_token = access_token - existing_access_token.data = json.dumps(data) existing_access_token.expires_in = expires_in else: db.session.add( http://git-wip-us.apache.org/repos/asf/cloudstack-gcestack/blob/34c685db/pyoauth2/provider.py ---------------------------------------------------------------------- diff --git a/pyoauth2/provider.py b/pyoauth2/provider.py index 12881fb..9d85ec8 100644 --- a/pyoauth2/provider.py +++ b/pyoauth2/provider.py @@ -181,6 +181,13 @@ class AuthorizationProvider(Provider): """ return 3600 + def generate_id_token(self): + """Generate a random authorization code. + + :rtype: str + """ + return 'ryJhbGciOiJSUzI1NiIsImtpZCI6IjRiODZiNDQxMmE2MmRiOWRmY2JkYjg2MWZlZmRjM2YwMzgzYjFlNDIifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiaWQiOiIxMTc1NTA3MTAxNzk0MTI2NTQxNzkiLCJzdWIiOiIxMTc1NTA3MTAxNzk0MTI2NTQxNzkiLCJhenAiOiIzMjU1NTk0MDU1OS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsImVtYWlsIjoiYnJvZ2FuZDkzQGRhcnJlbmJyb2dhbi5pZSIsImF0X2hhc2giOiJzdmVrRzJlVmc3YnpiRW91a05xY3FRIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImF1ZCI6IjMyNTU1OTQwNTU5LmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiaGQiOiJkYXJyZW5icm9nYW4uaWUiLCJ0b2tlbl9oYXNoIjoic3Zla0cyZVZnN2J6YkVvdWtOcWNxUSIsInZlcmlmaWVkX2VtYWlsIjp0cnVlLCJjaWQiOiIzMjU1NTk0MDU1OS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsImlhdCI6MTQwNjIzMTczOCwiZXhwIjoxNDA2MjM1NjM4fQ.QpvqKU_GWtqBdZsazpJs4UnuwkpVlOhYk6tYNNXhJSnbbLgpg847vbuMUEBM_vP03JB7Ot5P3AuSzSiBtXXB4hd8IU8puR4NYUMkrMfSNLYSGTyy1qf39v3LM10wsaUC4trw9eWPNHZoVimxhblfs-ocAyfiyFFizK8kdvWlM9w' + def generate_authorization_code(self): """Generate a random authorization code. @@ -317,6 +324,7 @@ class AuthorizationProvider(Provider): token_type = self.token_type expires_in = self.token_expires_in refresh_token = self.generate_refresh_token() + id_token = self.generate_id_token() # Save information to be used to validate later requests self.persist_token_information(client_id=client_id, @@ -332,6 +340,7 @@ class AuthorizationProvider(Provider): 'access_token': access_token, 'token_type': token_type, 'expires_in': expires_in, + 'id_token': id_token, 'refresh_token': refresh_token }) @@ -391,6 +400,7 @@ class AuthorizationProvider(Provider): token_type = self.token_type expires_in = self.token_expires_in refresh_token = self.generate_refresh_token() + id_token = self.generate_id_token() # Save information to be used to validate later requests self.persist_token_information(client_id=client_id, @@ -405,8 +415,8 @@ class AuthorizationProvider(Provider): return self._make_json_response({ 'access_token': access_token, 'token_type': token_type, + 'id_token': id_token, 'expires_in': expires_in, - 'refresh_token': refresh_token }) def get_authorization_code_from_uri(self, uri): @@ -442,8 +452,7 @@ class AuthorizationProvider(Provider): return self._invalid_redirect_uri_response() except Exception as exc: self._handle_exception(exc) - print exc.errno - print exc.strerror + # Catch all other server errors err = 'server_error' u = params['redirect_uri']