In Part 1, I introduced an app that sends an SMS notification when your Fitbit battery is low. Part 2 covers the Authentication Flow of the process.
The flow is as follows:
- User accesses the sign-up page (and by default, provides authorization via Fitbit.com). The request is passed through an API Gateway to a Lambda function. The Lambda function calls a Fitbit api to authenticate the user.
- The Fitbit authentication returns to the Lambda code. From there: (3) the token is saved to a DynamoDB database, (4) a message is placed on a SNS topic, and (5) a success response is sent back to the webpage
- The user information (access_token, refresh_token, and mobile number) is saved to a DynamoDB table
- An SNS topic receives the mobile number as a message
- A success message is sent back to the end user.
- The SNS topic (step 4) calls a second Lambda function.
- The Create_User_Topic lambda function creates a sns topic for the newly authenticated user.
- Once the topic is created, a notice is sent to the user’s mobile device – asking to confirm subscription.
- The user confirms the subscription.