Skip to content

Commit 948735a

Browse files
committed
fix: Remove unnecessary oauth type
1 parent 68bf33b commit 948735a

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

snowflake-api/src/requests.rs

-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ pub struct LoginRequest<T> {
1616

1717
pub type PasswordLoginRequest = LoginRequest<PasswordRequestData>;
1818
pub type OAuthLoginRequest = LoginRequest<OAuthRequestData>;
19-
pub type SPCSOAuthLoginRequest = LoginRequest<SPCSOAuthRequestData>;
2019
#[cfg(feature = "cert-auth")]
2120
pub type CertLoginRequest = LoginRequest<CertRequestData>;
2221

@@ -65,15 +64,6 @@ pub struct OAuthRequestData {
6564
pub authenticator: String,
6665
}
6766

68-
#[derive(Serialize, Debug)]
69-
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
70-
pub struct SPCSOAuthRequestData {
71-
#[serde(flatten)]
72-
pub login_request_common: LoginRequestCommon,
73-
pub token: String,
74-
pub authenticator: String,
75-
}
76-
7767
#[derive(Serialize, Debug)]
7868
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
7969
pub struct CertRequestData {

snowflake-api/src/session.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use crate::connection::{Connection, QueryType};
1414
use crate::requests::{CertLoginRequest, CertRequestData};
1515
use crate::requests::{
1616
ClientEnvironment, LoginRequest, LoginRequestCommon, OAuthLoginRequest, OAuthRequestData,
17-
PasswordLoginRequest, PasswordRequestData, RenewSessionRequest, SPCSOAuthLoginRequest,
18-
SPCSOAuthRequestData, SessionParameters,
17+
PasswordLoginRequest, PasswordRequestData, RenewSessionRequest, SessionParameters,
1918
};
2019
use crate::responses::AuthResponse;
2120

@@ -457,8 +456,15 @@ impl Session {
457456
}
458457

459458
async fn spcs_create(&self) -> Result<AuthTokens, AuthError> {
459+
// We should wait until we are ready to send the request
460+
// before we read the token, as it expires after 10 minutes
460461
let token = fs::read_to_string("/snowflake/session/token")
461462
.map_err(|_| AuthError::MissingSPCSOAuthToken)?;
463+
464+
// fixme: I am not sure if waiting until now to read all of these
465+
// is necessary or not, but I figured I would allow the user
466+
// to override these on instantiation and only replace the
467+
// user provided ones with the env provides ones if necessary
462468
let warehouse = self
463469
.warehouse
464470
.clone()
@@ -470,8 +476,8 @@ impl Session {
470476
let schema = self.warehouse.clone().or(env::var("SNOWFLAKE_SCHEMA").ok());
471477
let role = self.warehouse.clone().or(env::var("SNOWFLAKE_ROLE").ok());
472478

473-
let body = SPCSOAuthLoginRequest {
474-
data: SPCSOAuthRequestData {
479+
let body = OAuthLoginRequest {
480+
data: OAuthRequestData {
475481
login_request_common: self.login_request_common(),
476482
token,
477483
authenticator: "OAUTH".to_string(),

0 commit comments

Comments
 (0)