diff --git a/lib/workos/sso.ex b/lib/workos/sso.ex index 98534c7..fc974e0 100644 --- a/lib/workos/sso.ex +++ b/lib/workos/sso.ex @@ -146,15 +146,15 @@ defmodule WorkOS.SSO do * `:code` - The authorization value which was passed back as a query parameter in the callback to the Redirect URI. (required) """ - @spec get_profile_and_token(map()) :: WorkOS.Client.response(ProfileAndToken.t()) - @spec get_profile_and_token(WorkOS.Client.t(), map()) :: + @spec get_profile_and_token(String.t()) :: WorkOS.Client.response(ProfileAndToken.t()) + @spec get_profile_and_token(WorkOS.Client.t(), String.t()) :: WorkOS.Client.response(ProfileAndToken.t()) - def get_profile_and_token(client \\ WorkOS.client(), opts) do + def get_profile_and_token(client \\ WorkOS.client(), code) do WorkOS.Client.post(client, ProfileAndToken, "/sso/token", %{ client_id: WorkOS.client_id(client), client_secret: WorkOS.api_key(client), grant_type: "authorization_code", - code: opts[:code] + code: code }) end diff --git a/test/workos/sso_test.exs b/test/workos/sso_test.exs index 61b6ffb..6bf0e34 100644 --- a/test/workos/sso_test.exs +++ b/test/workos/sso_test.exs @@ -126,7 +126,7 @@ defmodule WorkOS.SSOTest do context |> ClientMock.get_profile_and_token(assert_fields: opts) assert {:ok, %WorkOS.SSO.ProfileAndToken{access_token: access_token, profile: profile}} = - WorkOS.SSO.get_profile_and_token(Map.new(opts)) + WorkOS.SSO.get_profile_and_token(opts |> Keyword.get(:code)) refute is_nil(access_token) refute is_nil(profile) @@ -140,7 +140,7 @@ defmodule WorkOS.SSOTest do |> ClientMock.get_profile_and_token(assert_fields: opts) {:ok, %WorkOS.SSO.ProfileAndToken{access_token: access_token, profile: profile}} = - WorkOS.SSO.get_profile_and_token(opts |> Map.new()) + WorkOS.SSO.get_profile_and_token(opts |> Keyword.get(:code)) refute is_nil(access_token) refute is_nil(profile)