def pass_creds_to_nylas(name, email, password, server_host=None):
<EOL>nylas_authorize_data = {<EOL>"<STR_LIT>": app.config["<STR_LIT>"],<EOL>"<STR_LIT:name>": name,<EOL>"<STR_LIT>": email,<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": {"<STR_LIT:username>": email, "<STR_LIT:password>": password},<EOL>}<EOL>if server_host:<EOL><INDENT>nylas_authorize_data["<STR_LIT>"]["<STR_LIT>"] = server_host<EOL><DEDENT>nylas_authorize_resp = requests.post(<EOL>"<STR_LIT>", json=nylas_authorize_data<EOL>)<EOL>if not nylas_authorize_resp.ok:<EOL><INDENT>message = nylas_authorize_resp.json()["<STR_LIT:message>"]<EOL>raise APIError(message)<EOL><DEDENT>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>if not nylas_token_resp.ok:<EOL><INDENT>message = nylas_token_resp.json()["<STR_LIT:message>"]<EOL>raise APIError(message)<EOL><DEDENT>nylas_access_token = nylas_token_resp.json()["<STR_LIT>"]<EOL>session["<STR_LIT>"] = nylas_access_token<EOL>return redirect(url_for("<STR_LIT:success>"))<EOL>
Passes Exchange credentials to Nylas, to set up native authentication.