denielchiang / line_reminder

Reminder using LINE Notify
1 stars 0 forks source link

Feature person subscriptions #46

Closed denielchiang closed 2 months ago

denielchiang commented 5 months ago

Now it's made for group chat, it's fine. But it's limited by how to create own token then send to admin.

Here's an idea, what if every single person who join this reading progress are able to subscribe the notification from our website. Wouldn't it be nice?

So basically will need to make a link, when someone clicked it with Line installed will apply token and preserve this token in our database. Once we need to send notification to that person, we can grab that token out and sent it.

Reference articles https://ithelp.ithome.com.tw/m/articles/10264918

denielchiang commented 5 months ago

Working on it now.

denielchiang commented 5 months ago

Problem

I got a issue from OAuth2 for Line Notify.

After I receiving the response from https://notify-bot.line.me/oauth/authorize It seems everything is okay, but once I sent to https://notify-bot.line.me/oauth/token asking for token, the response says invalid client_secret.

[info] GET /auth/line/callback
[debug] Processing with LineReminderWeb.AuthController.callback/2
  Parameters: %{"code" => "XXXXXXXXXXXXXXXXXXXX", "state" => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
  Pipelines: [:browser]
{:ok,
 %Req.Response{
   status: 400,
   headers: %{
     "cache-control" => ["no-cache, no-store, max-age=0, must-revalidate"],
     "content-type" => ["application/json"],
     "date" => ["Sat, 20 Jan 2024 07:17:14 GMT"],
     "expires" => ["0"],
     "keep-alive" => ["timeout=9"],
     "pragma" => ["no-cache"],
     "server" => ["nginx"],
     "strict-transport-security" => ["max-age=31536000 ; includeSubDomains"],
     "transfer-encoding" => ["chunked"],
     "x-content-type-options" => ["nosniff"],
     "x-frame-options" => ["DENY"],
     "x-xss-protection" => ["0"]
   },
   body: %{
     "access_token" => nil,
     "message" => "invalid client_secret",
     "status" => 400
   },
   trailers: %{},
   private: %{}
 }}

It turns out the wording of the response were so beat around the bush!

How to fix

Apply a new Line Service with whole brand new client_id and client_secret.

Potential cause

Too much notify has been sent, so it might hit some limit of Line Notify API.

denielchiang commented 5 months ago

Got a problem that couldn't get the env variables from module attribute, since baking module attribute will be the compile time. And I'm using fly secrets instead. So removed those module attributes and changed them as private functions to get values is working. Thanks Chris McCord

lib/line_reminder_web/controllers/auth_controller.ex

denielchiang commented 2 months ago

i will close this feature for now. it has been tested on only one general group record by QR Code scanning from the page.