Skip to main content

upstox_rust_sdk/models/login/
google_oauth2_request.rs

1use serde::Serialize;
2
3#[derive(Serialize, Debug)]
4#[serde(rename_all = "snake_case")]
5pub enum ResponseType {
6    Code,
7}
8
9#[derive(Serialize, Debug)]
10#[serde(rename_all = "snake_case")]
11pub enum AccessType {
12    Offline,
13}
14
15#[derive(Serialize, Debug)]
16#[serde(rename_all = "snake_case")]
17pub enum Prompt {
18    Consent,
19    SelectAccount,
20}
21
22#[derive(Serialize, Debug)]
23#[serde(rename_all = "snake_case")]
24pub enum GrantType {
25    AuthorizationCode,
26    RefreshToken,
27}
28
29#[derive(Serialize, Debug)]
30pub enum CodeChallengeMethod {
31    S256,
32    #[serde(rename = "plain")]
33    Plain,
34}
35
36#[derive(Serialize, Debug)]
37pub struct GoogleOAuth2AuthRequest {
38    pub client_id: String,
39    pub redirect_uri: String,
40    pub response_type: ResponseType,
41    pub scope: String,
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub code_challenge: Option<String>,
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub code_challenge_method: Option<CodeChallengeMethod>,
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub state: Option<String>,
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub login_hint: Option<String>,
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub access_type: Option<AccessType>,
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub prompt: Option<Prompt>,
54}
55
56#[derive(Serialize, Debug)]
57pub struct GoogleOAuth2CodeTokenRequest {
58    pub client_id: String,
59    pub client_secret: String,
60    pub code: String,
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub code_verifier: Option<String>,
63    pub grant_type: GrantType,
64    pub redirect_uri: String,
65}
66
67#[derive(Serialize, Debug)]
68pub struct GoogleOAuth2RefreshTokenRequest {
69    pub client_id: String,
70    pub client_secret: String,
71    pub grant_type: GrantType,
72    pub refresh_token: String,
73}