@@ -31,14 +31,17 @@ function _assert_pkg_server_env_var_is_set()
3131end
3232
3333"""
34- authenticate(server::AbstractString)
34+ authenticate(server::AbstractString; kwargs... )
3535
3636Starts interactive (blocking) browser-based Pkg server authentication for the Pkg
3737server specified by `server`. Also sets the `$(pkg_server_env_var_name) ` environment
3838variable to `server`.
3939
4040`server` must be the URL of a valid Pkg server.
4141
42+ ## Keyword arguments
43+ - `modify_environment::Bool = true`: Set the `$(pkg_server_env_var_name) ` environment variable to server.
44+
4245## Example usage
4346
4447```julia
@@ -50,13 +53,20 @@ function authenticate(
5053 auth_suffix:: Union{String, Nothing} = nothing ,
5154 force:: Union{Bool, Nothing} = nothing ,
5255 tries:: Union{Integer, Nothing} = nothing ,
56+ modify_environment:: Bool = true ,
5357):: Union{Success, Failure}
54- ENV [pkg_server_env_var_name] = server
55- authenticate (;
56- auth_suffix = auth_suffix,
57- force = force,
58- tries = tries,
59- )
58+ if modify_environment
59+ ENV [pkg_server_env_var_name] = server
60+ end
61+ # Even if `modify_environment` is `false`, we still need to set the environment
62+ # variable for the duration of the `authenticate` call.
63+ withenv (pkg_server_env_var_name => server)
64+ authenticate (;
65+ auth_suffix = auth_suffix,
66+ force = force,
67+ tries = tries,
68+ )
69+ end
6070end
6171
6272"""
0 commit comments