Skip to content

Commit 39e6c40

Browse files
committed
use SMART App v2 scopes
1 parent bdafc2c commit 39e6c40

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

server/app.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,30 @@
1414
app = Flask(__name__)
1515
bb = BlueButton()
1616

17+
## helper trouble shoot
18+
def print_setting():
19+
print("URL::BlueButton->base_url: {}".format(bb.base_url), flush=True)
20+
print("URL::BlueButton->auth_base_url: {}".format(bb.auth_base_url), flush=True)
21+
print("URL::BlueButton->auth_token_url: {}".format(bb.auth_token_url), flush=True)
22+
print("URL::BlueButton->callback_url: {}".format(bb.callback_url), flush=True)
23+
24+
25+
app = Flask(__name__)
26+
bb = BlueButton()
27+
28+
host_ip = os.environ.get("HOST_IP")
29+
30+
print_setting()
31+
32+
if host_ip:
33+
if str(bb.base_url).startswith("http://localhost"):
34+
bb.base_url = str(bb.base_url).replace("http://localhost", "http://{}".format(host_ip))
35+
if str(bb.auth_base_url).startswith("http://localhost"):
36+
bb.auth_base_url = str(bb.auth_base_url).replace("http://localhost", "http://{}".format(host_ip))
37+
if str(bb.auth_token_url).startswith("http://localhost"):
38+
bb.auth_token_url = str(bb.auth_token_url).replace("http://localhost", "http://{}".format(host_ip))
39+
print_setting()
40+
1741
# This is where medicare.gov beneficiary associated
1842
# with the current logged in app user,
1943
# in real app, this could be the app specific
@@ -35,7 +59,11 @@
3559

3660
@app.route('/api/authorize/authurl', methods=['GET'])
3761
def get_auth_url():
38-
redirect_url = bb.generate_authorize_url(auth_data)
62+
# for SMART App v2 scopes usage: explicitly
63+
# provide query parameter scope=<v2 scopes>
64+
# where <v2 scopes> is space delimited v2 scope specs (url encoded)
65+
# e.g. patient/ExplanationOfBenefit.rs
66+
redirect_url = bb.generate_authorize_url(auth_data) + "&scope=patient%2FPatient.s%20patient%2FExplanationOfBenefit.rs"
3967
return redirect_url
4068

4169

0 commit comments

Comments
 (0)