KoenZomers / OneDriveAPI

API in .NET Framework 4.8.0, .NET Core 3.1 and .NET 6.0 to communicate with OneDrive Personal and OneDrive for Business
Eclipse Public License 1.0
109 stars 34 forks source link

Exception when call GetAccessToken() #19

Closed 632575987 closed 4 years ago

632575987 commented 5 years ago

Im using it on xamarin.forms


var uri = onedriveAPI.GetAuthenticationUri();
            browser.Source = uri;
            browser.Navigated += async (ss, ee) =>
            {
                Debug.WriteLine(ee.Url);

                // Get the currently displayed URL and show it in the textbox
                var url = ee.Url.ToString();

                // Check if the current URL contains the authorization token
                var authorizationCodeTxt = onedriveAPI.GetAuthorizationTokenFromUrl(ee.Url.ToString());

                // Verify if an authorization token was successfully extracted
                if (!string.IsNullOrEmpty(authorizationCodeTxt))
                {
                    //onedriveAPI. = authorizationCodeTxt;
                    // Get an access token based on the authorization token that we now have
                    var tok = await onedriveAPI.GetAccessToken();
                    if (onedriveAPI.AccessToken != null)
                    {
                        // Show the access token information in the textboxes```
}}}

the app can get the authorization token, but when i click the 'yes' button on the brower to enable the access, and then the app throw an exception: Operation is not valid due to the current state of the object.

屏幕快照 2019-05-06 下午12 51 42

KoenZomers commented 5 years ago

Try running Fiddler while you're making the call and look at the network traffic that gets generated. This likely already shows some abnormalities.

KoenZomers commented 4 years ago

Closing due to no response received.

stoee commented 4 years ago

DemoApplication.

Failed to retrieve OneDrive access token. Additional information: AADSTS70002: The provided request must include a 'client_secret' input parameter. image image

{"error":"invalid_client","error_description":"AADSTS70002: The provided request must include a 'client_secret' input parameter.\r\nTrace ID: 7b409a52-de5e-4c38-b76f-7c13ebd16a01\r\nCorrelation ID: 5f5bc486-b01e-49d6-b373-4bcebce3c213\r\nTimestamp: 2020-01-14 02:43:51Z","error_codes":[70002],"timestamp":"2020-01-14 02:43:51Z","trace_id":"7b409a52-de5e-4c38-b76f-7c13ebd16a01","correlation_id":"5f5bc486-b01e-49d6-b373-4bcebce3c213","error_uri":"https://login.microsoftonline.com/error?code=70002"}

KoenZomers commented 4 years ago

Which ClientID are you using to make the requests? Your own or the one in the code already?

If your own, ensure you have "Treat application as public client" set to Yes in your Azure Active Directory App Registration under the Authentication section: image

KoenZomers commented 4 years ago

Closing as no further response received.