A Flutter library for LinkedIn OAuth 2.0 APIs .
This library is using new way of authorization on LinkedIn
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.
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()}');
},
)
String firstName;
String lastName;
String accessToken;
int expiresIn;
String profilePicture;
String email;
Standard LinkedIn button for login. This widget is modifiable.
LinkedInButtonStandardWidget(onTap: () {});
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.
example/README.md
Demonstrates how to use the linkedin_login library. Link to directory.
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});
}
Add this to your package's pubspec.yaml file:
dependencies:
linkedin_login: ^0.1.1
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.
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 |
|
|
0.1.0 | Jan 23, 2019 |
|
|
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
|
We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
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 |