Code Monkey home page Code Monkey logo

linkedin_login's Introduction

linkedin_login

Codacy Badge codecov

  • A Flutter library for LinkedIn OAuth 2.0 APIs .
  • This library is using new way of authorization on LinkedIn

⭐⭐⭐⭐ Star ⭐⭐⭐⭐ a repo if you like project. Your support matters to us.⭐⭐⭐⭐

Installation

Important

You should replace this values

final String redirectUrl = 'YOUR-REDIRECT-URL';
final String clientId = 'YOUR-CLIENT-ID';
final String clientSecret = 'YOUR-CLIENT-SECRET';

Note: clientSecret field is required just for LinkedInUserWidget

To get these values you need to create App on the LinkedIn.

Samples

You can see full example under this project.

Call LinkedIn authorization and get user object:

    LinkedInUserWidget(
       redirectUrl: redirectUrl,
       clientId: clientId,
       clientSecret: clientSecret,
       onGetUserProfile:
           (LinkedInUserModel linkedInUser) {
                print('Access token ${linkedInUser.token.accessToken}');
                print('First name: ${linkedInUser.firstName.localized.label}');
                print('Last name: ${linkedInUser.lastName.localized.label}');
       },
       catchError: (LinkedInErrorObject error) {
         print(
             'Error description: ${error.description},'
             ' Error code: ${error.statusCode.toString()}');
        },
    )

Or you can just fetch authorization code (clientSecret is not required in this widget):

    LinkedInAuthCodeWidget(
        redirectUrl: redirectUrl,
        clientId: clientId,
        onGetAuthCode:
            (AuthorizationCodeResponse response) {
                print('Auth code ${response.code}');
                print('State: ${response.state}');
            },
    ),

If you want to logout user (to clear session from webview) all you need is to forward true value to property destroySession in LinkedInUserWidget or LinkedInAuthCodeWidget. Please don't forget to destroy your data in your local storage for this user. Currently, LinkedIn doesn't have API point on OAuth 2 which will destroy access token.

Properties that are available after call for LinkedInUserWidget

  String firstName;
  String lastName;
  String accessToken;
  int expiresIn;
  String profilePicture;
  String email;
  String userId; (from version 0.1.)

Projection - which properties of user account will be accessible via LinkedIn API

Available from version 1.2.x

You can control projection, by providing array of strings to projection property of widget LinkedInUserWidget. By default these properties are included:

  static const String id = "id";
  static const String localizedLastName = "localizedLastName";
  static const String firstName = "firstName";
  static const String lastName = "lastName";
  static const String localizedFirstName = "localizedFirstName";

You can include also profilePicture to get URL of user profile image. If you change this property to some custom value you will override default values, and you need to add every of these manually to array. For more info see example project.

Properties that are available after call for LinkedInAuthCodeWidget

  String code; // authorization code
  String state;

Widgets

Standard LinkedIn button for login. This widget is modifiable.

LinkedInButtonStandardWidget(onTap: () {});

linkedin_login's People

Contributors

codacy-badger avatar d3xt3r2909 avatar javierduartec avatar ricardonior29 avatar

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.