@app.route("<STR_LIT>")<EOL>def pass_creds_to_nylas():
<EOL>if not google.authorized:<EOL><INDENT>return "<STR_LIT>", <NUM_LIT><EOL><DEDENT>if "<STR_LIT>" not in google.token:<EOL><INDENT>return (<EOL>(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>),<EOL><NUM_LIT>,<EOL>)<EOL><DEDENT>google_resp = google.get("<STR_LIT>")<EOL>assert google_resp.ok, "<STR_LIT>"<EOL>google_userinfo = google_resp.json()<EOL>nylas_authorize_data = {<EOL>"<STR_LIT>": app.config["<STR_LIT>"],<EOL>"<STR_LIT:name>": google_userinfo["<STR_LIT:name>"],<EOL>"<STR_LIT>": google_userinfo["<STR_LIT:email>"],<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": {<EOL>"<STR_LIT>": app.config["<STR_LIT>"],<EOL>"<STR_LIT>": app.config["<STR_LIT>"],<EOL>"<STR_LIT>": google.token["<STR_LIT>"],<EOL>},<EOL>}<EOL>nylas_authorize_resp = requests.post(<EOL>"<STR_LIT>", json=nylas_authorize_data<EOL>)<EOL>assert nylas_authorize_resp.ok, "<STR_LIT>"<EOL>nylas_code = nylas_authorize_resp.json()["<STR_LIT:code>"]<EOL>nylas_token_data = {<EOL>"<STR_LIT>": app.config["<STR_LIT>"],<EOL>"<STR_LIT>": app.config["<STR_LIT>"],<EOL>"<STR_LIT:code>": nylas_code,<EOL>}<EOL>nylas_token_resp = requests.post(<EOL>"<STR_LIT>", json=nylas_token_data<EOL>)<EOL>assert nylas_token_resp.ok, "<STR_LIT>"<EOL>nylas_access_token = nylas_token_resp.json()["<STR_LIT>"]<EOL>session["<STR_LIT>"] = nylas_access_token<EOL>return redirect(url_for("<STR_LIT:index>"))<EOL>
This view loads the credentials from Google and passes them to Nylas,
to set up native authentication.