Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: support signing in with msft account #195820

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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