async def authenticate_with_device(atv):
credentials = await atv.airplay.generate_credentials()<EOL>await atv.airplay.load_credentials(credentials)<EOL>try:<EOL><INDENT>await atv.airplay.start_authentication()<EOL>pin = input('<STR_LIT>')<EOL>await atv.airplay.finish_authentication(pin)<EOL>print('<STR_LIT>'.format(credentials))<EOL><DEDENT>except exceptions.DeviceAuthenticationError:<EOL><INDENT>print('<STR_LIT>', file=sys.stderr)<EOL><DEDENT>
Perform device authentication and print credentials.