Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't i use msaAuthProvider.AuthenticateUserAsync() in .Net Core 3.1 #70

Open
muscankaraoglu opened this issue May 2, 2020 · 5 comments

Comments

@muscankaraoglu
Copy link

muscankaraoglu commented May 2, 2020

image

As you can see,
when i came on await msaAuthProvider.AuthenticateUserAsync(); line it throws this exception.
I couldn't find any answer for this issue in .net core.
Is this supports .net core 3.1?

Can anyone help me?

@Mogikan
Copy link

Mogikan commented Sep 4, 2020

Seem like it is a dead repository and no one cares to reply. I wonder how to contact their management staff.

@muscankaraoglu
Copy link
Author

I am also curious, but I solved the problem as follows; I don't use the OneDrive API anymore :)

@Mogikan
Copy link

Mogikan commented Sep 5, 2020

@muscankaraoglu you need to build it against .net core 3.1. Since Microsoft Graph Core does not support RefreshToken you need to remove corresponding code, but only in adal and business code, not in msaAuthProvider.

@chrisgriffis
Copy link

chrisgriffis commented Nov 9, 2021

I am also curious, but I solved the problem as follows; I don't use the OneDrive API anymore :)

the problem is here:

httpProvider.Serializer.DeserializeObject<IDictionary<string, string>>(

the problem is that some json vals in response (like ttl, for example) are pure numeric and not strings, and so deserialize is throwing when it tries to interp the first num it sees as a string.

the workaround is o provide your own serializer that correctly parses the string as Json, and then converts it to the type param:

        public class MySer : ISerializer
        {
            public T DeserializeObject<T>(System.IO.Stream stream)
            {
                return DeserializeObject<T>(new System.IO.StreamReader(stream).ReadToEnd());
            }

            public T DeserializeObject<T>(string inputString)
            {
                var j = JObject.Parse(inputString);
                return j.ToObject<T>();
            }

            public string SerializeObject(object serializeableObject)
            {
                throw new NotImplementedException();
            }
        }

@Mogikan
Copy link

Mogikan commented Nov 15, 2021

I am also curious, but I solved the problem as follows; I don't use the OneDrive API anymore :)

the problem is here:

httpProvider.Serializer.DeserializeObject<IDictionary<string, string>>(

the problem is that some json vals in response (like ttl, for example) are pure numeric and not strings, and so deserialize is throwing when it tries to interp the first num it sees as a string.

the workaround is o provide your own serializer that correctly parses the string as Json, and then converts it to the type param:

        public class MySer : ISerializer
        {
            public T DeserializeObject<T>(System.IO.Stream stream)
            {
                return DeserializeObject<T>(new System.IO.StreamReader(stream).ReadToEnd());
            }

            public T DeserializeObject<T>(string inputString)
            {
                var j = JObject.Parse(inputString);
                return j.ToObject<T>();
            }

            public string SerializeObject(object serializeableObject)
            {
                throw new NotImplementedException();
            }
        }

I fixed it in OAuthHelper.cs
Instead of
var responseValues =
httpProvider.Serializer.DeserializeObject<IDictionary<string, string>>(
responseStream);
I use:
var rawValues = httpProvider.Serializer.DeserializeObject<Dictionary<string, object>>(responseStream);
var responseValues = rawValues.ToDictionary(item => item.Key, item => item.Value.ToString());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants