Microsoft.Graph.API gives Code: generalException Message: Unexpected exception returned from the service - c#-4.0

I am using Microsoft.graph.API for getting OneDrive user data.
I registered my application through Azure AD v2.0 and got access token and refersh token also successfully. But when I am trying to access impersonated user through Admin credential that time i am getting following exception:
Code: generalException Message: Unexpected exception returned from the service.
In this inner exception is null.
Thank you.
c#-4.0
Thank you.

Related

Unauthorized Exception in OAuthPrompt in MS Teams Bot GCC High

I have create a Bot using https://github.com/microsoft/BotBuilder-Samples/blob/main/samples/csharp_dotnetcore/46.teams-auth/ this template.
for user Authentication I am using OAuthPromt but getting this exception
Operation returned an invalid status code 'Unauthorized'
return await stepContext.BeginDialogAsync(nameof(OAuthPrompt), null, cancellationToken);
at Dialogs/MainDialog.cs
Please help me
thanks
It appears to be Authentication Token Error i.e OAuth. Azure AAD is unable to issue a token to your bot APP registration. I would suggest you go through the documentation here step by step and also make sure Bot IDs, Bot Passwords are correct.

AADSTS700016: Failed to obtain access token when authenticating to Azure with MSAL

I would like to authenticate to Azure using MSAL, which I specified as follows:
app = msal.ConfidentialClientApplication(
client_id=client_id,
client_credential=client_secret,
authority='https://login.microsoftonline.com/' + tenantname
)
result = app.acquire_token_for_client(scopes=scopes)
It fails because it cannot find the company's tenantname I have access to even though it's correctly specified.
Error description was: AADSTS700016: Application with identifier '12341234123somethingtest-fje2434823412341234123somethingtest-4322134-213413212341234123somethingtest' was not found in the directory '213412312341234123somethingtest-1234-3241'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant. Exception: Failed to obtain access token
I've tried tenantname and tenant ID from the AAD as well and always got the same error.
Is there any way to resolve this issue? (The code worked perfectly when I used it on my own Azure.)
Your error has been resolved. It is caused by lack of characters in your client_id. You only need to enter the correct client_id.
Encountered similar problems, can run admin consent url debugging in the browser:
https://login.microsoftonline.com/{tenant-id}/adminconsent?client_id={client-id}.

In botframework-sdk all of a sudden my bot started to get this error Error: Get Token request returned http error: 401

All of a sudden my bot started to get this error:
[onTurnError] unhandled error: Error: Get Token request returned http error: 401 and server response: {"error":"invalid_client","error_description":"AADSTS7000222: The provided client secret keys are expired. Visit the Azure Portal to create new keys for your app, or consider using certificate credentials for added security: https://learn.microsoft.com/azure/active-directory/develop/active-directory-certificate-credentials\r\nTrace ID: 91097c7f-35a4-4f95-97bc-d616a6b45100\r\nCorrelation ID: e0110013-d13c-4897-aafc-f2e36a194ed5\r\nTimestamp: 2021-03-01 20:00:25Z","error_codes":[7000222],"timestamp":"2021-03-01 20:00:25Z","trace_id":"91097c7f-35a4-4f95-97bc-d616a6b45100","correlation_id":"e0110013-d13c-4897-aafc-f2e36a194ed5","error_uri":"https://login.microsoftonline.com/error?code=7000222"}
It sounds like your Direct Line secret has expired, assuming you are trying to hit https://directline.botframework.com/v3/directline/tokens/generate. You can regenerate them by going to the Bot Service blade, selecting your Bot Service, and then clicking on Channels. Click Edit on your Direct Line channel and you'll have the option to regenerate your key(s).

MS Graph API: Access denied when trying to create a list, even with Sites.ReadWrite.All application permissions

According to the docs, to create a list, a Sites.ReadWrite.All application permission is needed.
I have an Azure app with exactly that permission:
Yet, when trying to create a list I still get access denied.
403 : Forbidden
[...]
[Some information was truncated for brevity, enable debug logging for more details]
Exception in thread "main" com.microsoft.graph.http.GraphServiceException: Error code: accessDenied
Error message: Access denied
The full output can be found here. The complete code which reproduces the behavior can be found here. The application requires access without a user. The access token is generated through a client assertion flow.
The question is: What's wrong here? Is it the documentation which is outdated? Or am I doing something wrong?

Trying O365 Authentication in Xamarin forms app

We are new to O365 Authentication and trying to authenticate the user.
Here i am getting this error while trying to login with, office 365.
Create app in active directory add app id and return urls in app, and this is the document I followed, https://blog.xamarin.com/put-adal-xamarin-forms/
here is the error we are getting,
AADSTS70002: The request body must contain the following parameter: 'client_secret or client_assertion'
Trace ID: e580114e-2dd9-4cc4-b903-6cef743a2900
Correlation ID: 6e58ff9d-bea4-4ad3-9fe3-e27c92fc9597
Timestamp: 2018-12-05 12:51:23Z
{System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized). ---> Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException: {"error":"invalid_client","error_description":"AADSTS70002: The request body must contain the following parameter: 'client_secret or client_assertion'\r\nTrace ID: e580114e-2dd9-4cc4-b903-6cef743a2900\r\nCorrelation ID: 6e58ff9d-bea4-4ad3-9fe3-e27c92fc9597\r\nTimestamp: 2018-12-05 12:51:23Z","error_codes":[70002],"timestamp":"2018-12-05 12:51:23Z","trace_id":"e580114e-2dd9-4cc4-b903-6cef743a2900","correlation_id":"6e58ff9d-bea4-4ad3-9fe3-e27c92fc9597"}: Unknown error
--- End of inner exception stack trace ---}
Ok ,Maybe you have registered your app as a confidential client (web app or web api).
You cannot authenticate with username and password when the app is a confidential client. Only public clients, sometimes known as native clients, can do U/P authentication.
Trying to Change to native client.
Refer to this link to try

Resources