public async Task <IActionResult> GetV1AuthCodeAsync() { TokenTool.Microsoft.v1.AccessToken accessToken; TokenTool.Microsoft.v1.AccessToken refreshedToken; var queryString = this.Request.QueryString.ToString(); var authorizationCodeGrant = new TokenTool.Microsoft.v1.AuthorizationCodeGrant() { ClientId = config["v1Endpoint:clientId"], ClientSecret = config["v1Endpoint:clientSecret"], Scope = config["v1Endpoint:scopes"], RedirectUri = "http://localhost:64191/auth/authcode", Resource = "https://graph.microsoft.com" }; using (HttpClient httpClient = new HttpClient()) { accessToken = await authorizationCodeGrant.ProcessAuthorizationResponse(queryString); refreshedToken = await authorizationCodeGrant.RefreshAccessToken(accessToken.RefreshToken); } var idToken = TokenTool.Microsoft.IDToken.Parse(accessToken.IdToken); return(new JsonResult(new { accessToken, refreshedToken, idToken }, new JsonSerializerSettings() { Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore })); }
private void Setupv1() { var authorizationCodeGrant = new TokenTool.Microsoft.v1.AuthorizationCodeGrant() { ClientId = config["v1Endpoint:clientId"], Resource = config["v1Endpoint:defaultResource"], Scope = config["v1Endpoint:scopes"], RedirectUri = "http://localhost:64191/auth/v1authcode", Prompt = "login" }; V1AuthUri = authorizationCodeGrant.AuthorizationUri; var implicitGrant = new TokenTool.Microsoft.v1.ImplicitGrant() { ClientId = config["v1Endpoint:clientId"], Scope = config["v1Endpoint:scopes"], RedirectUri = "http://localhost:64191/", Resource = "https://graph.microsoft.com", Prompt = "consent" }; V1ImplicitUri = implicitGrant.AuthorizationUri; }