Skip to content

Commit 454a376

Browse files
committed
Add OAuth2 AuthZ Server Metadata example
1 parent f77b41f commit 454a376

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/examples/metadata.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import bottle
2+
from bottle_oauthlib.oauth2 import BottleOAuth2
3+
from oauthlib import oauth2
4+
5+
app = bottle.Bottle()
6+
app.auth = BottleOAuth2(app)
7+
app.authmetadata = BottleOAuth2(app)
8+
9+
oauthlib_server = oauth2.LegacyApplicationServer(oauth2.RequestValidator())
10+
app.authmetadata.initialize(oauth2.MetadataEndpoint([oauthlib_server], claims={
11+
"issuer": "https://xx",
12+
"token_endpoint": "https://xx/token",
13+
"revocation_endpoint": "https://xx/revoke",
14+
"introspection_endpoint": "https://xx/tokeninfo"
15+
}))
16+
17+
18+
@app.get('/.well-known/oauth-authorization-server')
19+
@app.authmetadata.create_metadata_response()
20+
def metadata():
21+
pass
22+
23+
24+
if __name__ == "__main__":
25+
app.run() # pragma: no cover

0 commit comments

Comments
 (0)