Coder Social home page Coder Social logo

Comments (10)

ejsmith avatar ejsmith commented on September 25, 2024

+1

from oauth2.

ArtsevDmitry avatar ArtsevDmitry commented on September 25, 2024

For example, need phone, but this property not presented in UserInfo :)

from oauth2.

jordisan avatar jordisan commented on September 25, 2024

We are using your fantastic library , but now we need to get additional user info from LinkedIn; concretely, the country of the user (inside location): https://developer.linkedin.com/docs/fields/basic-profile

Note that location is a structured data item, so maybe key-value pairs is not the best solution.

What do you recommend us? Extending your library somehow? Thanks

from oauth2.

niemyjski avatar niemyjski commented on September 25, 2024

Previously in a different library, we always parsed the data into key value pairs. Currently this functionality isn't available (myself or someone needs to build it) but we should have a dictionary where we can return all the extended data items.

from oauth2.

niemyjski avatar niemyjski commented on September 25, 2024

In this case you could parse it out into location.name = value or you could store it as json?

from oauth2.

jordisan avatar jordisan commented on September 25, 2024

Maybe we could add a AllData member to UserInfo class... (maybe XDocument or JObject); and then store there all the user data coming from the server

from oauth2.

ejsmith avatar ejsmith commented on September 25, 2024

I would think you would want to store the values in a dictionary and not use something that is transport specific like jobject and xdoc.

from oauth2.

jordisan avatar jordisan commented on September 25, 2024

Sure, @ejsmith ... I was just thinking about a quick-and-dirty solution :)

from oauth2.

weihangChen avatar weihangChen commented on September 25, 2024

I got this working in a quick way, without modifying existing API

using System.Collections.Generic;
using System.Linq;
using OAuth2.Configuration;
using OAuth2.Infrastructure;
using OAuth2.Models;
using OAuth2.Client;

namespace OAuth2.Example.Models
{
    public class MyGoogleClient : OAuth2.Client.Impl.GoogleClient
    {

        public MyGoogleClient(IRequestFactory factory, IClientConfiguration configuration)
            : base(factory, configuration)
        {
        }


        protected override UserInfo ParseUserInfo(string content)
        {
            return base.ParseUserInfo(content);
        }

    }

    public class MyAuthorizationRoot : AuthorizationRoot
    {
        private readonly IRequestFactory _requestFactory;
        private readonly OAuth2ConfigurationSection _configurationSection;

        public MyAuthorizationRoot() :
            this(new ConfigurationManager(), "oauth2", new RequestFactory())
        {
        }

        public MyAuthorizationRoot(
           IConfigurationManager configurationManager,
           string configurationSectionName,
           IRequestFactory requestFactory)
        {
            _requestFactory = requestFactory;
            _configurationSection = configurationManager
                .GetConfigSection<OAuth2ConfigurationSection>(configurationSectionName);
        }

        public override IEnumerable<IClient> Clients
        {
            get
            {
                var clients = base.Clients.ToList();
                var googleClient = clients.FirstOrDefault(x => x.Name == "Google");
                var newGoogleClient = new MyGoogleClient(_requestFactory, googleClient.Configuration);

                clients.Remove(googleClient);
                clients.Add(newGoogleClient);

                return clients;
            }
        }


    }
}

from oauth2.

niemyjski avatar niemyjski commented on September 25, 2024

I don't see where you are storing the extra info? I think we should add a dictionary on the user info and stick it in there. Would anyone like to take a stab at this?

from oauth2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.