diff --git a/lib/boruta/oauth/authorization/access_token.ex b/lib/boruta/oauth/authorization/access_token.ex index c7d56338..5999ec69 100644 --- a/lib/boruta/oauth/authorization/access_token.ex +++ b/lib/boruta/oauth/authorization/access_token.ex @@ -32,12 +32,19 @@ defmodule Boruta.Oauth.Authorization.AccessToken do :ok <- Token.ensure_valid(token) do {:ok, token} else + {:error, msg} -> + {:error, + %Error{ + status: :bad_request, + error: :invalid_access_token, + error_description: msg + }} _ -> {:error, %Error{ status: :bad_request, error: :invalid_access_token, - error_description: "Given access token is invalid, revoked, or expired." + error_description: "Given access token is invalid." }} end end diff --git a/lib/boruta/oauth/schemas/token.ex b/lib/boruta/oauth/schemas/token.ex index ee4063c4..f35604d5 100644 --- a/lib/boruta/oauth/schemas/token.ex +++ b/lib/boruta/oauth/schemas/token.ex @@ -121,8 +121,8 @@ defmodule Boruta.Oauth.Token do :ok | {:error, String.t()} def ensure_valid(token, type \\ :access_token) do case {revoked?(token, type), expired?(token, type)} do - {true, _} -> {:error, "Token revoked."} - {_, true} -> {:error, "Token expired."} + {true, _} -> {:error, "Given access token is revoked."} + {_, true} -> {:error, "Given access token is expired."} _ -> :ok end end diff --git a/test/boruta/openid/integration/userinfo_test.exs b/test/boruta/openid/integration/userinfo_test.exs index 539c684f..f0033dfe 100644 --- a/test/boruta/openid/integration/userinfo_test.exs +++ b/test/boruta/openid/integration/userinfo_test.exs @@ -47,7 +47,7 @@ defmodule Boruta.OpenidTest.UserinfoTest do assert {:unauthorized, %Boruta.Oauth.Error{ error: :invalid_access_token, - error_description: "Given access token is invalid, revoked, or expired.", + error_description: "Given access token is invalid.", status: :bad_request }} = Openid.userinfo(conn, ApplicationMock) end @@ -110,7 +110,7 @@ defmodule Boruta.OpenidTest.UserinfoTest do assert {:unauthorized, %Boruta.Oauth.Error{ error: :invalid_access_token, - error_description: "Given access token is invalid, revoked, or expired.", + error_description: "Given access token is invalid.", status: :bad_request }} = Openid.userinfo(conn, ApplicationMock) end