Created
January 28, 2018 01:48
-
-
Save piedoom/354f0d7750a6ea851cd4de7e40c4c2c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use reqwest; | |
pub const AUTH_PATH : &str = "https://login.microsoftonline.com/1318d57f-757b-45b3-b1b0-9b3c3842774f/oauth2/authorize"; | |
pub const TOKEN_PATH : &str = "https://login.microsoftonline.com/1318d57f-757b-45b3-b1b0-9b3c3842774f/oauth2/token"; | |
pub const AUTH_RESOURCE_PATH : &str = "https://wegmans-es.azure-api.net"; | |
// Get a bearer token | |
pub fn authorize(client_id: &str, client_secret: &str, redirect_uri: &str) { | |
// build our request | |
let mut rest_client = reqwest::Client::new(); | |
// make a request to get our token | |
let mut auth = rest_client.post(TOKEN_PATH) | |
.form( &[ | |
("client_id", client_id), | |
("grant_type", "client_credentials"), | |
("redirect_uri", redirect_uri), | |
("resource", AUTH_RESOURCE_PATH), | |
("client_secret", client_secret) | |
]) | |
.send(); | |
println!("{:?}", auth.unwrap().text()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment