Platform
Sign Up With LinkedIn
10 min
sign in with linkedin tutorial introduction sign in with linkedin enables users to sign in to apps using their linkedin accounts prerequisites to complete this tutorial, you will need an app created at back4app see the create new app tutorial to learn how to create an app at back4app set up a subdomain for your back4app app see activating your web hosting and live query to learn how to create a subdomain in back4app a linkedin developer account 1 create a new back4app app first of all, it’s necessary to make sure that you have an existing app created at back4app however, if you are a new user, you can check this tutorial https //www back4app com/docs/get started/new parse app to learn how to create one 2 create a new linkedin app log into your linkedin developer account https //www linkedin com/developers click create app create app and choose oauth client id oauth client id choose an app name and fill in the required fields such as business email business email and app logo app logo agree to the terms and click create app create app in your newly created app, click verify verify to verify the ownership of the app you must be the owner or administrator of the linkedin page to verify in the verification page, click generate url generate url visit the generated verification url verification url using the admin or owner account of the company’s page on linkedin click on approve verification approve verification make sure your app is verified in your app, go to the auth auth tab, fill in the redirect urls redirect urls field, and click update update 3 retrieve your code visit the following url, changing the values for client id client id , redirect url redirect url , and a random string a random string for the ones you created the random string is to avoid csrf attacks log in with your linkedin account and the redirected website will have your code in the url copy the code part of the url only and run the following curl command replacing the values your code your code , your client id your client id , your client secret your client secret , and your redirect uri your redirect uri for the values of your application 1 curl x post \\ 2 https //www linkedin com/oauth/v2/accesstoken \\ 3 h 'cache control no cache' \\ 4 h 'content type application/x www form urlencoded' \\ 5 d 'client id=your client id\&client secret=your client secret\&redirect uri=your redirect uri\&code=your code\&grant type=authorization code' run it and you should retrieve your access token remember the code can be used only once if you get an error or don’t use your token, you must re generate your code to be able to run it again 4 start the development now that the sign in with linkedin is configured, you can start the development process the format for authdata is 1 { 2 "linkedin" { 3 "id" "user's linkedin id (string)", 4 "access token" "an authorized linkedin access token for the user", 5 "is mobile sdk" true|false // set to true if you acquired the token through linkedin mobile sdk 6 } 7 } here is the method for the ios sdk 1 pfuser loginwithauthtype(inbackground "linkedin", authdata \["access token"\ tokenstring, "id" user, "is mobile sdk" true]) continuewith { task > any? in 2 3 } and here for the android sdk 1 map\<string, string, bool> authdata = new hashmap\<string, string, bool>(); 2 authdata put("access token", tokenstring); 3 authdata put("id", user); 4 authdata put("is mobile sdk", true); 5 task\<parseuser> t = parseuser loginwithinbackground("google", authdata); 6 t continuewith(new continuation\<parseuser, void>() { 7 public void then(task task) throws exception { 8 if (task iscancelled()) { 9 log w(tag, "task cancelled"); 10 } else if (task isfaulted()) { 11 log w(tag, "save fail" + task geterror()); 12 utilities showtoast(getresources() getstring(r string errorlogin) + task geterror(), mainactivity this); 13 } else { 14 // the object was saved successfully 15 parseuser user = (parseuser)task getresult(); 16 log w(tag, "success " + user getobjectid() + " " + user getusername() + " " + user getemail() + " " + user getsessiontoken()); 17 } 18 } 19 }