Skip to content

Commit

Permalink
cli: support signing in with msft account (#195820)
Browse files Browse the repository at this point in the history
  • Loading branch information
connor4312 committed Oct 17, 2023
1 parent c1434a8 commit f75db45
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cli/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

use crate::{
constants::{get_default_user_agent, PRODUCT_NAME_LONG},
constants::{get_default_user_agent, IS_INTERACTIVE_CLI, PRODUCT_NAME_LONG},
debug, error, info, log,
state::{LauncherPaths, PersistedState},
trace,
Expand Down Expand Up @@ -37,7 +37,7 @@ struct DeviceCodeResponse {
expires_in: i64,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug)]
struct AuthenticationResponse {
access_token: String,
refresh_token: Option<String>,
Expand Down Expand Up @@ -76,15 +76,15 @@ impl AuthProvider {
pub fn code_uri(&self) -> &'static str {
match self {
AuthProvider::Microsoft => {
"https://login.microsoftonline.com/common/oauth2/v2.0/devicecode"
"https://login.microsoftonline.com/organizations/oauth2/v2.0/devicecode"
}
AuthProvider::Github => "https://github.com/login/device/code",
}
}

pub fn grant_uri(&self) -> &'static str {
match self {
AuthProvider::Microsoft => "https://login.microsoftonline.com/common/oauth2/v2.0/token",
AuthProvider::Microsoft => "https://login.microsoftonline.com/organizations/oauth2/v2.0/token",
AuthProvider::Github => "https://github.com/login/oauth/access_token",
}
}
Expand Down Expand Up @@ -670,7 +670,11 @@ impl Auth {
}

async fn prompt_for_provider(&self) -> Result<AuthProvider, AnyError> {
if std::env::var("VSCODE_CLI_ALLOW_MS_AUTH").is_err() {
if !*IS_INTERACTIVE_CLI {
info!(
self.log,
"Using Github for authentication, pass the `--provider` option to change this."
);
return Ok(AuthProvider::Github);
}

Expand Down

0 comments on commit f75db45

Please sign in to comment.