Last active
March 25, 2020 22:59
-
-
Save sethdefontenay/cd5b6eab9403e48c0a49bcc579c20323 to your computer and use it in GitHub Desktop.
Xero OAuth2
This file contains 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
public void Test() | |
{ | |
// log in to the users xero account | |
// send this call using browser: https://login.xero.com/identity/connect/authorize?response_type=code&client_id=E****************E&redirect_uri=https%3A%2F%2F**************************%2Fapi%2FAuthorize&scope=openid profile email offline_access accounting.transactions&state=123 | |
// it should redirect to the function app which will send back the code | |
// the code only works once | |
HttpClient client = new HttpClient(); | |
var clientId = "*******E"; | |
var secret = "Q***********q"; | |
client.SetToken("Basic", Base64Encode($"{clientId}:{secret}")); | |
var values = new Dictionary<string, string> | |
{ | |
{ "grant_type", "authorization_code" }, | |
{ "authorization", "6*********************************5" }, // paste code here | |
{ "redirect_uri", "https://**************/api/Authorize" } | |
}; | |
var content = new FormUrlEncodedContent(values); | |
var response = client.PostAsync("https://identity.xero.com/connect/token", content).Result; | |
var responseString = response.Content.ReadAsStringAsync().Result; | |
} |
Follow instructions in the commented lines
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From where i can get authorization code