Quantcast
Channel: Azure Active Directory forum
Viewing all articles
Browse latest Browse all 16000

AADSTS70001: Application '574c1791-d632-4180-91e4-38094a8a3a77' is not supported for this API version

$
0
0
I am trying to use office365 api in my single page .net application not an mvc. I got the source code for mvc .net project C# in the website itself.

   
 public async Task<ActionResult> SignIn()               {                   
string authority = "https://login.microsoftonline.com/common";               

 string clientId = System.Configuration.ConfigurationManager.AppSettings["ida:ClientID"];

AuthenticationContext
authContext = new AuthenticationContext(authority);     

// The url in our app that Azure should redirect to after successful signin

Uri redirectUri = new Uri(Url.Action("Authorize", "Home", null, Request.Url.Scheme));                           

//Generate the parameterized URL for Azure signin           

Uri authUri = await authContext.GetAuthorizationRequestUrlAsync(scopes, null, clientId, redirectUri, UserIdentifier.AnyUser, null);        

// Redirect the browser to the Azure signin page           

return Redirect(authUri.ToString());               

}                                   // Note the function signature is changed!                   

public async Task<ActionResult> Authorize()                    {                       

// Get the 'code' parameter from the Azure redirect                        string authCode = Request.Params["code"];                                   
string authority = "https://login.microsoftonline.com/common";                       

string clientId = System.Configuration.ConfigurationManager.AppSettings["ida:ClientID"]; ;                       

string clientSecret = System.Configuration.ConfigurationManager.AppSettings["ida:ClientSecret"]; ;                       

AuthenticationContext authContext = new AuthenticationContext(authority);                         

 // The same url we specified in the auth code request                    
 Uri redirectUri = new Uri(Url.Action("Authorize", "Home", null, Request.Url.Scheme));                                 
 // Use client ID and secret to establish app identity       

ClientCredential credential = new ClientCredential(clientId, clientSecret);                   try                       
 {
 // Get the token                           

var authResult = await authContext.AcquireTokenByAuthorizationCodeAsync(          authCode, redirectUri, credential, scopes);                                       
// Save the token in the session                           
Session["access_token"] = authResult.Token;                 // Try to get user info                           

Session["user_email"] = GetUserEmail(authContext,clientId);                                       
return Redirect(Url.Action("Inbox", "Home", null,Request.Url.Scheme));                        }                       
catch (AdalException ex)                       {                           
return Content(string.Format("ERROR retrieving token: {0}", ex.Message));                       }                   }



 I converted the code to vb.net and i am receiving bad request error stating that my application is not supported for this api version when executed. The code is in WebForm1.aspx and the redirect uri link is to webform2.aspx


   
Private Sub SignIn()                  

Dim authority As String = "https://login.microsoftonline.com/common" 

Dim clientId As String = System.Configuration.ConfigurationManager.AppSettings("ida:ClientID") 

Dim authContext As New AuthenticationContext(authority)               

Dim redirectUri As New Uri("http://localhost:26683/WebForm2.aspx") 

Dim authUri As Uri = authContext.GetAuthorizationRequestURL("https://outlook.office.com/mail.read", clientId, redirectUri, UserIdentifier.AnyUser, Nothing)   

Response.Redirect(authUri.ToString())    
End Sub



However i have registered the application.In fact when i used the same client id  and client secret for the mvc application it is executed without any error but when i use it in my single web application it throws this error.
Please help.What am i doing wrong

Viewing all articles
Browse latest Browse all 16000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>