Skip to content

Commit

Permalink
Pass code as keyword argument
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraBeatris committed Dec 12, 2023
1 parent b5fc11e commit c6d0342
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/workos/sso.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions test/workos/sso_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit c6d0342

Please sign in to comment.