mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 01:32:35 -05:00
cli: support signing in with msft account (#195820)
For https://github.com/microsoft/vscode-remote-release/issues/8908
This commit is contained in:
@@ -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,
|
||||
@@ -37,7 +37,7 @@ struct DeviceCodeResponse {
|
||||
expires_in: i64,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct AuthenticationResponse {
|
||||
access_token: String,
|
||||
refresh_token: Option<String>,
|
||||
@@ -76,7 +76,7 @@ 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",
|
||||
}
|
||||
@@ -84,7 +84,7 @@ impl AuthProvider {
|
||||
|
||||
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",
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user