- (Implemented in version of 3.0.0 of this library) A Flutter library for LinkedIn OAuth 2.0 APIs .
- (Deprecated from LinkedIn and removed from this library after v3.0.0) A Flutter library for LinkedIn OAuth 2.0 APIs .
- This library is using authorization from LinkedIn API
- See the installation instructions on pub
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.
- Please check your
minSdkVersion
for different setup: -- If you are usingHybrid Composition
(default from version 2.1.0) yourminSdkVersion
should be at least 19 -- If you want to useVirtual displays
(default before version 2.1.0) yourminSdkVersion
should be at least 20
To read more why this lib needs to use one of these two modes please visit docs of webview_flutter
Since LinkedIn introduce new way of signing in with LinkedIn called "Sign In with LinkedIn using OpenID Connect" and they are deprecating and removing "Sign In with LinkedIn" from product list (see LinkedIn console where you have created your app) this library needs to have few breaking changes duo change of architecture. Sorry for that in advance.
- Projection property no longer exists since
/me
API is removed and from now on library is using/userinfo
docs - Previous scopes are removed (r_emailaddress, r_liteprofile) and introduces new ones:
openid
,email
,profile
- All fields on user response are flatten (see example project) and some are not existing anymore
- Response that you can get from LinkedIn with new API looks like this
{
"sub": "xxxx",
"email_verified": true,
"name": "xxxx",
"locale": {
"country": "US",
"language": "en"
},
"given_name": "xxxx",
"family_name": "xxxx",
"email": "xxxx",
"picture": "xxxx"
}
For more details about this change you can navigate to this issue
You can see full example under this project.
Call LinkedIn authorization and get user object:
LinkedInUserWidget(
redirectUrl: redirectUrl,
clientId: clientId,
clientSecret: clientSecret,
onGetUserProfile:
(UserSucceededAction linkedInUser) {
print('Access token ${linkedInUser.user.token}');
print('First name: ${linkedInUser.user.givenName}');
print('Last name: ${linkedInUser.user.familyName}');
},
onError: (UserFailedAction e) {
print('Error: ${e.toString()}');
},
)
Or you can just fetch authorization code (clientSecret is not required in this widget):
LinkedInAuthCodeWidget(
redirectUrl: redirectUrl,
clientId: clientId,
onGetAuthCode:
(AuthorizationSucceededAction response) {
print('Auth code ${response.codeResponse.code}');
print('State: ${response.codeResponse.state}');
},
onError: (AuthorizationFailedAction e) {
print('Error: ${e.toString()}');
},
),
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.
String name;
String familyName;
String givenName;
bool isEmailVerified;
String sub;
String accessToken;
int expiresIn;
String picture;
String email;
LinkedInPreferredLocal locale; (from version 0.1.)
r_emailaddress
and r_liteprofile
scopes will be removed from LinkedIn after 30 of November and they are removed from library after 3.x.x version.
Now you should add under "Products" -> "Sign In With LinkedIn using OpenID Connect"
https://www.linkedin.com/developers/apps/{REPLACE_WITH_ID_OF_YOUR_APP}/products
OpenId is requiring openid scope with in combination of at least Email or Profile scope, but by default this library is adding three scopes
final scopes = const [
OpenIdScope(),
EmailScope(),
ProfileScope(),
],
You are also able to create custom scopes by extending Scope
class
class CustomScope extends Scope {
const CustomScope() : super('whatever_scope_of_name_to_map_with_linkedin_api');
}
However please take in consideration limitations of this library under section known limitations
inside this file.
String code; // authorization code
String state;
Standard LinkedIn button for login. This widget is modifiable.
LinkedInButtonStandardWidget(onTap: () {});
- To regenerate mocks and generated files please run:
flutter packages pub run build_runner build --delete-conflicting-outputs
- Best and shortest explanation why library is not supporting this is hidden behind this (comment)[#28 (comment)]
- If you have (access)[https://stackoverflow.com/a/57979607/6074443] to (developer partner program)[https://linkedin.zendesk.com/hc/en-us] I would really appreciate if you could submit pull request on this feature.
- As Firebase is not supporting LinkedIn out of the box this is not implemented inside the library and its heavy consuming time to implement custom solution, anyhow if someone is willing to submit PR I would really love to approve it
- Web is still not supported at it requires a lot of JS work, as LinkedIn doesn't allow that their API is injected into iFrame