2017-11-21 1 views
1

저는 Flask, Twilio 및 Ngrok를 사용하여 Raspberry Pi에서 프로그램을 실행하고 있습니다. 브라우저에서 ngrok URL에 액세스 할 때 ngrok의 사용자 이름/비밀번호 인증이 제대로 작동하지만 인증을 위해 문자 메시지에 username/pw를 전달하고 코드를 계속 전달하고자합니다.비밀 번호가있는 Twilio와 Ngrok?

심지어 가능합니까?

app = Flask(__name__) 

@app.route("/", methods=['GET', 'POST']) 
def camera_toggle(): 
    from_number = request.values.get('From', None) 
    from_message = request.values.get('Body', None) 

    resp = MessagingResponse() 
    resp.message("Please enter your username:password") 
    if ":" not in from_message: 
     #Split the username/password, then somehow login?? 
     return str(resp) 
    else: 
     from_number = request.values.get('From', None) 
     from_message = request.values.get('Body', None) 
     if callers[from_number] == "John Doe": 
      if from_message == "CameraON": 
       subprocess.call(["bash", "camera.sh"]) 
     return str("Please enter the keyword to turn on the camera") 

이 경우에도 가능합니까?

답변

2

여기에 Twilio 개발자 전도사가 있습니다.

ngrok와 함께 HTTP 기본 인증을 사용하는 경우 들어오는 SMS 메시지의 URL에 사용자 이름과 암호를 사용하도록 Twilio webhook URL을 설정할 수 있습니다.

예를 들어, 사용자 이름과 암호는 "사용자 이름"과 "암호"를했다하고 ngrok URL은 secure.ngrok.io 다음 당신이 당신의 Twilio 콘솔에서 메시지 수신은 webhook URL을 설정할 수 있다면 :

https://username:[email protected]/sms

securing your webhook endpoints in the Twilio documentation에서 자세한 내용을 확인하십시오.

+0

감사합니다. @philnash. 예제 코드를 이해하는 데 어려움을 겪고 있으며 필요한 코드를 구현하는 방법을 잘 모릅니다. SMS를 통해 사용자 이름/암호를 입력하라는 논리를 어떻게 포함 시킬지는 모르겠다. –

+0

아, 사용자 이름과 암호를 묻는 메시지를 표시하려면 ngrok의 HTTP 기본 인증을 사용할 수 없습니다. 응용 프로그램 자체에 인증을 구축해야합니다. – philnash