Package: cardboard.py
cardboard.pycardboard.py is a Python library for interacting with the cardboard API.PyPi:https://pypi.org/project/cardboard.py/InstallationYou can install the cardboard.py library using pip:pip install cardboard.pyQuartIntegrationpip install cardboard.py[Quart]FlaskIntegrationpip install cardboard.py[Flask]UsageInitialize the Cardboard or CardboardAsync class. Make sure to passsecretandclient_id.You can now use the client to make requests.ExamplesThese examples will use Flask. Install it withpip install FlaskFlask is included withcardboard.py>=0.0.8Incardboard.py>=0.0.16, you can install it withpip install cardboard.py[Flask]# Python ExamplefromflaskimportFlask,request,redirect,url_for,session,ResponsefromcardboardimportCardboardapp=Flask(__name__)cb=Cardboard(client_id='',secret='')# get these at https://cardboard.inkapp.secret_key='hi'# set this to something secure, please.@app.route('/login')deflogin():args=request.argscode=args.get('code')ifnotcode:returnredirect(cb.app_url)try:token=cb.get_token(code)except:returnredirect(cb.app_url)session['cardboard_token']=token.tokenreturnredirect(url_for('dashboard'))@app.route('/dashboard')defdashboard():token=session.get('cardboard_token')ifnottoken:returnredirect(cb.app_url)user=cb.get_user(token)returnResponse(f'{user.name}(user id{user.id})',mimetype='text/plain')@app.route('/')defhome():html=f'<html><head><title>Button Redirect</title></head><body><button onclick="window.location.href=\'{url_for("login")}\';">Login</button></body></html>'returnResponse(html,mimetype='text/html')@app.route('/logout')deflogout():b=session.pop('cardboard_token',None)ifb:try:cb.revoke_token(b)except:passreturnredirect(url_for('home'))if__name__=='__main__':app.run('0.0.0.0',port=5000)# Python Example using FlaskIntegrationfromflaskimportFlask,request,redirect,url_for,session,ResponsefromcardboardimportCardboard,FlaskIntegrationapp=Flask(__name__)app.secret_key='hi'# set this to something secure, please.cb=Cardboard(client_id='',secret='')# get these at https://cardboard.inkcb.fi=FlaskIntegration(app=app,cardboard=cb)# make this class ONLY AFTER YOU SET A SECRET KEY for FLASK.@app.route('/login')@cb.fi.autologindeflogin(token):returnredirect(url_for('dashboard'))@app.route('/dashboard')@cb.fi.logged_indefdashboard(token):user=cb.get_user(token.token)returnResponse(f'{user.name}(user id{user.id})',mimetype='text/plain')@app.route('/')defhome():html=f'<html><head><title>Button Redirect</title></head><body><button onclick="window.location.href=\'{url_for("login")}\';">Login</button></body></html>'returnResponse(html,mimetype='text/html')@app.route('/logout')@cb.fi.autologoutdeflogout():returnredirect(url_for('home'))if__name__=='__main__':app.run('0.0.0.0',port=5000)Async Example# Python Async ExampleDocumentationFor detailed documentation on the Cardboard API, readhttps://www.guilded.gg/CardBoard/groups/3y446Rmz/channels/4539a4f9-fb51-4a23-b014-0fcaeaf062d3/docs/374610For detailed documentation on how to use the cardboard.py library, please wait while we write it lol.MethodsA list of methods/attributes you can call with either Cardboard or CardboardAsync..app_url(str).app_name(str).secret(str).client_id(str).revoke_token(token:str)(bool).get_token(code:str)(class AuthToken).token(str).token_type(str).refresh_token(str).expires_in(int)._raw(dict).refresh_token(refresh_token:str)(class AuthToken).token(str).token_type(str).refresh_token(str).expires_in(int)._raw(dict).get_user(token:str)(class User).name(str).id(str).subdomain(str).aliases(list(class UserAlias)).alias(str|None).discriminator(str|None).name(str).createdAt(datetime).editedAt(datetime)._raw_createdAt(str)._raw_editedAt(str).userId(str).gameId(int).socialLinkSource(str|None).socialLinkHandle(str|None).additionalInfo(dict).playerInfo(dict|None)._raw(dict).avatar(str).banner(str).status(class UserStatus).text(str|None).reaction_id(int|None)._raw(dict)._raw_text(dict)._raw_reaction(dict).moderationStatus(str|None).aboutInfo(class userAbout).bio(str|None).tagline(str|None)._raw(dict).userTransientStatus(str|None)._raw(dict).check_token(token:str)(bool)FlaskIntegration@logged_in@optional_logged_in@autologin@autologout@login_autoexchangeDEPRECATED@login_codeDEPRECATEDQuartIntegration@logged_in@optional_logged_in@autologin@autologout@login_autoexchangeDEPRECATED@login_codeDEPRECATEDLicenseThis project is licensed under the MIT License. See the LICENSE file for details.