feature/smbcloud-deploy
claude/smbcloud-github-app-k9641p
development
feature/apps
feature/build-release
feature/ci-docs
feature/ci-ruby-gems
feature/cicd
feature/completion
feature/dist-nuget
feature/fix-ci-sdk-pypi-rubygem
feature/fix-clippy-on-stable-channel
feature/fix-deployment-script
feature/github-email
feature/gresiq-v1
feature/project-new-structure
feature/rsync-deploy
feature/ruby-runner
feature/sdk-npm
feature/sdk-workflows
feature/smbcloud-cli-release-npm
feature/smbcloud-deploy
feature/wasm
main
release/v0.7.4
| 1 | use { |
| 2 | log::debug, |
| 3 | reqwest::Client, |
| 4 | serde_json::json, |
| 5 | smbcloud_model::{ |
| 6 | error_codes::ErrorResponse, |
| 7 | oauth::{OauthRedirect, TokenResponse}, |
| 8 | }, |
| 9 | smbcloud_network::network::{self}, |
| 10 | }; |
| 11 | |
| 12 | pub async fn get_token( |
| 13 | oauth_redirect: OauthRedirect, |
| 14 | client_id: String, |
| 15 | client_secret: String, |
| 16 | ) -> Result<TokenResponse, ErrorResponse> { |
| 17 | let base_url = "https://oauth2.googleapis.com/token".to_string(); |
| 18 | debug!("Exchange code with token: {:?}", oauth_redirect.code); |
| 19 | let paylod = json!({ |
| 20 | "client_id": client_id, |
| 21 | "client_secret": client_secret, |
| 22 | "code": oauth_redirect.code, |
| 23 | "grant_type": "authorization_code", |
| 24 | "redirect_uri": "http://localhost:8000" |
| 25 | }); |
| 26 | let builder = Client::new().post(base_url).json(&paylod); |
| 27 | network::request(builder).await |
| 28 | } |