Skip to content

Instantly share code, notes, and snippets.

@zupzup
Created October 29, 2020 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zupzup/7d1253b8d798a071ebca5f1f31f668b4 to your computer and use it in GitHub Desktop.
Save zupzup/7d1253b8d798a071ebca5f1f31f668b4 to your computer and use it in GitHub Desktop.
Timeular Public API sign_in 2
#[derive(Serialize, Debug)]
#[serde(rename_all = "camelCase")]
struct SignInRequest {
api_key: String,
api_secret: String,
}
#[derive(Deserialize, Debug)]
struct SignInResponse {
token: String,
}
async fn sign_in(api_key: String, api_secret: String) -> Result<String, Error> {
let body = SignInRequest {
api_key,
api_secret,
};
let resp = CLIENT
.post(&url("/developer/sign-in"))
.json(&body)
.send()
.await?
.json::<SignInResponse>()
.await?;
Ok(resp.token)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment