def require_iogrow_user(cls, action=None): token = endpoints.users_id_token._get_token(None) token_stored = Tokens.query(Tokens.token == token).get() if token_stored: return token_stored.user.get() token = endpoints.users_id_token._get_token(None) # will get the token info from the dict token_info = _SAVED_TOKEN_DICT.get(token) if token_info is None: # will get the token info from network result = cls.get_token_info(token) if result.status_code != 200: raise endpoints.UnauthorizedException(cls.INVALID_TOKEN) token_info = json.loads(result.content) _SAVED_TOKEN_DICT[token] = token_info if 'email' not in token_info: raise endpoints.UnauthorizedException(cls.INVALID_TOKEN) email = token_info['email'] user_from_email = User.get_by_email(email) if user_from_email is None: raise endpoints.UnauthorizedException(cls.NO_ACCOUNT) store_new_token = Tokens(token=token, user=user_from_email.key, email=user_from_email.email) store_new_token.put() return user_from_email
def predict(predd, tedd): user = User.get_by_email('*****@*****.**') credentials = user.google_credentials http = credentials.authorize(httplib2.Http()) service = build('prediction', 'v1.6', http=http) result = service.trainedmodels().predict(project='935370948155-qm0tjs62kagtik11jt10n9j7vbguok9d', id='7', body={ 'input': {'csvInstance': ['Sofware Engineer', 'Purchase List']}}).execute() return result
def predict(predd, tedd): user = User.get_by_email('*****@*****.**') credentials = user.google_credentials http = credentials.authorize(httplib2.Http()) service = build('prediction', 'v1.6', http=http) result = service.trainedmodels().predict( project='935370948155-qm0tjs62kagtik11jt10n9j7vbguok9d', id='7', body={ 'input': { 'csvInstance': ['Sofware Engineer', 'Purchase List'] } }).execute() return result