Add web sample for using google-auth for end-user auth (#1127) · renxiaoming/python-docs-samples@57de3e0 · GitHub
Skip to content

Commit 57de3e0

Browse files
author
Jon Wayne Parrott
authored
Add web sample for using google-auth for end-user auth (GoogleCloudPlatform#1127)
* Add web sample for using google-auth for end-user auth Change-Id: I90856d5da694b9eab1b363f7982638482e10429a * Use apiclient Change-Id: Icb43629fa835682eeb0a248dbb56e12b15d0dd15 * Address review comments Change-Id: I3f7492601a6ec7f64dab611928dc1d6c5a23d9af * Fix missing redirect uri Change-Id: I98ea11e842c679caf944b134e745013962c5c34a * Fix some wording Change-Id: I44d4c690c8fb3702988cb303d4afc9872331bb32
1 parent a75e025 commit 57de3e0

3 files changed

Lines changed: 163 additions & 0 deletions

File tree

auth/end-user/web/main.py

Lines changed: 119 additions & 0 deletions

auth/end-user/web/main_test.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2017 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import pytest
16+
17+
import main
18+
19+
# Note: samples that do end-user auth are difficult to test in an automated
20+
# way. These tests are basic sanity checks.
21+
22+
23+
@pytest.fixture
24+
def client():
25+
main.app.testing = True
26+
return main.app.test_client()
27+
28+
29+
def test_index_wo_credentials(client):
30+
r = client.get('/')
31+
assert r.status_code == 302
32+
assert r.headers['location'].endswith('/authorize')
33+
34+
35+
def test_authorize(client):
36+
r = client.get('/authorize')
37+
assert r.status_code == 302
38+
assert r.headers['location'].startswith('https://accounts.google.com')

auth/end-user/web/requirements.txt

Lines changed: 6 additions & 0 deletions

0 commit comments

Comments
 (0)