aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMartin Kühl <martin.kuehl@gmail.com>2018-08-29 01:07:17 +0200
committerMartin Kühl <martin.kuehl@gmail.com>2018-09-01 23:10:48 +0200
commitad2a7972e75e8738147aa5e67b6db04b45800b3c (patch)
treed02872831a0c22b60e3e140b738e8ea8807526c1 /lib
parentb60d2327199965a165c8456a487f929f9ef56651 (diff)
downloadpleroma-ad2a7972e75e8738147aa5e67b6db04b45800b3c.tar.gz
OAuth: Set `created_at` in token exchange response
(for compatibility with Mastodon)
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/oauth/oauth_controller.ex4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex
index a5fb32a4e..934171585 100644
--- a/lib/pleroma/web/oauth/oauth_controller.ex
+++ b/lib/pleroma/web/oauth/oauth_controller.ex
@@ -60,11 +60,13 @@ defmodule Pleroma.Web.OAuth.OAuthController do
fixed_token = fix_padding(params["code"]),
%Authorization{} = auth <-
Repo.get_by(Authorization, token: fixed_token, app_id: app.id),
- {:ok, token} <- Token.exchange_token(app, auth) do
+ {:ok, token} <- Token.exchange_token(app, auth),
+ {:ok, inserted_at} <- DateTime.from_naive(token.inserted_at, "Etc/UTC") do
response = %{
token_type: "Bearer",
access_token: token.token,
refresh_token: token.refresh_token,
+ created_at: DateTime.to_unix(inserted_at),
expires_in: 60 * 10,
scope: "read write follow"
}