Skip to main content
#NCTU-Oauth

台灣國立交通大學推出了 [NCTU Oauth](https://id.nctu.edu.tw/),現在,你可以透過本套件在 Flask 使用 NCTU Oauth。

依據[交通大學 OAuth 服務 - 開發者說明文件](https://id.nctu.edu.tw/docs/)進行相對應的開發,以下是一個使用本套件開發之範例。

```Python
#-*- encoding: UTF-8 -*-

from flask import Flask, session, request, redirect, jsonify

# Our oauth
from nctu_oauth import Oauth

NCTU_APP_REDIRECT_URI = 'In this example is http://your.domain.name/auth'
NCTU_APP_CLIENT_ID = 'your client id'
NCTU_APP_CLIENT_SECRET = 'your client secret'

app = Flask(__name__)
app.secret_key = 'your super coll secrey key'

# make a oauth init
nctu = Oauth(
redirect_uri=NCTU_APP_REDIRECT_URI,
client_id=NCTU_APP_CLIENT_ID,
client_secret=NCTU_APP_CLIENT_SECRET
)

@app.route("/")
def home():
# check if login
if session.get('logged_in'):
# get user profile
return jsonify(nctu.get_profile())

return redirect('/login')

@app.route('/login')
def login():
# redirect to nctu auth dialog
return nctu.authorize()

@app.route('/auth')
def auth():
# user code for getting token
code = request.args.get('code')
if code:
#get user token
if nctu.get_token(code):
return redirect('/')

return redirect('/login')


if __name__ == "__main__":
app.run()
```

Metadata

Release files for NCTU-Oauth 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for NCTU-Oauth 0.1.0
File Size Uploaded Provenance Actions
NCTU-Oauth-0.1.0.tar.gz 2.3 kB Without provenance Details for NCTU-Oauth-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for NCTU-Oauth 0.1.0
File Interpreter ABI Platform Actions
NCTU_Oauth-0.1.0-py2.7.egg Legacy Egg format - - Details for NCTU_Oauth-0.1.0-py2.7.egg

Total release size: 6.3 kB

Release files / NCTU-Oauth-0.1.0.tar.gz

Download URL NCTU-Oauth-0.1.0.tar.gz
Size 2.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c86f749f003035c9ba6665b88ca679969aee956a4b2ebce52427dd3bddf36697
BLAKE2b-256 checksum
How to use checksums
2bb8c3f9ffe1692a1e22786b7bcd3901c4c2b2ccfee9c66fd2a92438d8758aa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / NCTU_Oauth-0.1.0-py2.7.egg

Download URL NCTU_Oauth-0.1.0-py2.7.egg
Size 4.0 kB
Tags Egg
SHA-256 checksum
How to use checksums
77673c70ec39f89564004242bd174594a8b83a33f8777e1343528bea19d8eae0
BLAKE2b-256 checksum
How to use checksums
5e07c6508378015a0c79d81c8878b7163e7ab97f21ecbb911a752c60eb927605
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for NCTU-Oauth 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page