linkedin_login 0.1.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new80

linkedin_login #

  • A Flutter library for LinkedIn OAuth 2.0 APIs .

  • This library is using new way of authorization on LinkedIn

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';

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()}');
                                  },
)

Properties that are available after call #

  String firstName;
  String lastName;
  String accessToken;
  int expiresIn;
  String profilePicture;
  String email;

Widgets #

Standard LinkedIn button for login. This widget is modifiable.

LinkedInButtonStandardWidget(onTap: () {});

Changelog #

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v0.1.0 - 2019-01-23 #

Added #

  • Login with LinkedIn support to Android and IOS using pure dart
  • LinkedIn default button
  • Retrieve basic user information from linked login with email and token

example/README.md

linkedin_login #

Demonstrates how to use the linkedin_login library. Link to directory.

example #

import 'package:flutter/material.dart';
import 'package:linkedin_login/linkedin_login.dart';

void main() => runApp(MyApp());

// @TODO IMPORTANT - you need to change variable values below
// You need to add your own data from LinkedIn application
// From: https://www.linkedin.com/developers/
// Please read step 1 from this link https://developer.linkedin.com/docs/oauth2
final String redirectUrl = 'YOUR-REDIRECT-URL';
final String clientId = 'YOUR-CLIENT-ID';
final String clientSecret = 'YOUR-CLIENT-SECRE';

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter LinkedIn demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: LinkedInExamplePage(),
    );
  }
}

class LinkedInExamplePage extends StatefulWidget {
  @override
  State createState() => _LinkedInExamplePageState();
}

class _LinkedInExamplePageState extends State<LinkedInExamplePage> {
  UserObject user;

  @override
  Widget build(BuildContext context) => Scaffold(
        backgroundColor: Colors.white,
        appBar: AppBar(
          title: Text('LinkedIn login'),
        ),
        body: Center(
          child: Container(
              child: user == null
                  ? LinkedInButtonStandardWidget(
                      onTap: () {
                        Navigator.push(
                          context,
                          MaterialPageRoute(
                            builder: (BuildContext context) =>
                                LinkedInUserWidget(
                                  redirectUrl: redirectUrl,
                                  clientId: clientId,
                                  clientSecret: clientSecret,
                                  onGetUserProfile:
                                      (LinkedInUserModel linkedInUser) {
                                    print(
                                        'Access token ${linkedInUser.token.accessToken}');

                                    user = UserObject(
                                      firstName: linkedInUser
                                          .firstName.localized.label,
                                      lastName:
                                          linkedInUser.lastName.localized.label,
                                      email: linkedInUser.email.elements[0]
                                          .handleDeep.emailAddress,
                                    );

                                    Navigator.pop(context);

                                    setState(() {});
                                  },
                                  catchError: (LinkedInErrorObject error) {
                                    print(
                                        'Error description: ${error.description},'
                                        ' Error code: ${error.statusCode.toString()}');
                                    Navigator.pop(context);
                                  },
                                ),
                            fullscreenDialog: true,
                          ),
                        );
                      },
                    )
                  : Container(
                      child: Column(
                        mainAxisSize: MainAxisSize.max,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Text('First: ${user.firstName} '),
                          Text('Last: ${user.lastName} '),
                          Text('Email: ${user.email}'),
                        ],
                      ),
                    )),
        ),
      );
}

class UserObject {
  String firstName, lastName, email;

  UserObject({this.firstName, this.lastName, this.email});
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  linkedin_login: ^0.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:linkedin_login/linkedin_login.dart';
  
Version Uploaded Documentation Archive
0.1.1 Jan 23, 2019 Go to the documentation of linkedin_login 0.1.1 Download linkedin_login 0.1.1 archive
0.1.0 Jan 23, 2019 Go to the documentation of linkedin_login 0.1.0 Download linkedin_login 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
60
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
80
Learn more about scoring.

We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13+1
  • Flutter: 1.2.1

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
flutter_webview_plugin ^0.3.0+2 0.3.0+2
http ^0.11.3+16 0.11.3+17 0.12.0+1
uuid ^1.0.3 1.0.3 2.0.0
Transitive dependencies
async 2.0.8
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
http_parser 3.1.3
meta 1.1.6 1.1.7
path 1.6.2
sky_engine 0.0.99
source_span 1.5.4
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test