Flutter: Sign in with LinkedIn

Introduction

Step 2:

dependencies: 
flutter_linkedin: ^1.0.2
flutter pub get

Step 3:

import ‘package:flutter_linkedin/linkedloginflutter.dart’;

Step 4:

@override
void initState() {
super.initState();
LinkedInLogin.initialize(context,
clientId: clientId,
clientSecret: clientSecret,
redirectUri: redirectUrl);
}

Step 5:

LinkedInLogin.loginForAccessToken(
destroySession: true,
appBar: AppBar(
title: Text('Demo Login Page'),
))
.then((accessToken) => print(accessToken))
.catchError((error) {
print(error.errorDescription);
});

Step 6:

LinkedInLogin.getProfile(
destroySession: true,
forceLogin: true,
appBar: AppBar(
title: Text('Demo Login Page'),
))
.then((profile) {
print('First name : ${profile.firstName}');
print('Last name : ${profile.lastName}');
print('Avatar: ${profile.profilePicture.profilePictureDisplayImage
.elements.first.identifiers.first.identifier}');
})
.catchError((error) {
print(error.errorDescription);
});

Step 7:

LinkedInLogin.getEmail(
destroySession: true,
forceLogin: true,
appBar: AppBar(
title: Text('Demo Login Page'),
)).then((email) {
print(
'Email : ${email.elements.first.elementHandle.emailAddress}');
}).catchError((error) {
print(error.errorDescription);
});

Conclusion

--

--

A group of tech enthusiastic people spreading their knowledge

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store