<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Aveek Das</title>
    <description>The latest articles on Forem by Aveek Das (@aveekd22).</description>
    <link>https://forem.com/aveekd22</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F568368%2F58822b00-2144-45ba-a9e5-9ab1003a3c48.jpg</url>
      <title>Forem: Aveek Das</title>
      <link>https://forem.com/aveekd22</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/aveekd22"/>
    <language>en</language>
    <item>
      <title>An Overview of AWS IAM Roles and Policies</title>
      <dc:creator>Aveek Das</dc:creator>
      <pubDate>Sat, 02 Jul 2022 09:15:27 +0000</pubDate>
      <link>https://forem.com/aveekd22/an-overview-of-aws-iam-roles-and-policies-1ha6</link>
      <guid>https://forem.com/aveekd22/an-overview-of-aws-iam-roles-and-policies-1ha6</guid>
      <description>&lt;p&gt;In this article, I am going to introduce the concept of AWS IAM, also known as Identity and Access Management in AWS. In any cloud service, controlling who has access to the services and how each of the services accesses the other services is an important task. If we do not control the access or restrict then there might be cases of a security breach within the services and we might not be able to track those as well. So as a best practice to restrict or control access within the AWS, there is a special service called IAM that can be used to manage and control almost everything in AWS. It is the permission control system that controls access to the various AWS resources and services.&lt;/p&gt;

&lt;p&gt;In order to follow along with this article, it is best suited that you have an AWS subscription which can be used to verify and understand the topics that we will use in this article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding AWS IAM components
&lt;/h2&gt;

&lt;p&gt;Identity and Access Management (IAM) is a service offered by Amazon to control the users, create groups and allow or deny access to specific resources within the AWS environment. You can use this service by logging into the AWS Management Console and search for IAM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4AOpVjMY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nc4livjpp9lt2yqde4px.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4AOpVjMY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nc4livjpp9lt2yqde4px.png" alt="Figure 1 – Amazon web services IAM Service in the AWS Management Console" width="880" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The AWS IAM service will be opened and you can see the following. There are four major components of the IAM service.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users&lt;/li&gt;
&lt;li&gt;Groups&lt;/li&gt;
&lt;li&gt;Roles&lt;/li&gt;
&lt;li&gt;Policies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DvSvPSJN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rh6gabzfntgtcmsdj327.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DvSvPSJN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rh6gabzfntgtcmsdj327.png" alt="Figure 2 – AWS IAM Dashboard" width="880" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us now understand each of the components in detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Users
&lt;/h2&gt;

&lt;p&gt;As per the definition from the official documentation, “An AWS Identity and Access Management (IAM) user is an entity that you create in AWS to represent the person or application that uses it to interact with AWS.”. Basically, you will have to create a user for each and every individual that you would want to access your AWS Account. There is also a possibility to create delegated users for your application, but that is out of scope for this article.&lt;/p&gt;

&lt;p&gt;There are two types of users in the AWS Management Console – Root User and IAM User.&lt;/p&gt;

&lt;p&gt;The Root user is the first user that is created when you create an AWS Account for the first time. It has access to every possible resource within the AWS Account. As a best practice, it is advised that you should not be using the root user for your daily activities, instead create an IAM user and use it for your development. The root user should only be used to perform specific activities such as billing etc.&lt;/p&gt;

&lt;p&gt;The AWS IAM user is one that you create using your root user and can be used to login to the console later. Once the IAM user is created, you should start using it for your daily activities and leave the root user account secured.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xGuYKCqX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ih9n952aopg8f4oc8z8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xGuYKCqX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ih9n952aopg8f4oc8z8.png" alt="Figure 3 – IAM Users" width="880" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Groups
&lt;/h2&gt;

&lt;p&gt;As you might have guessed, in AWS IAM, the groups are a collection of IAM users. Using groups you can get rid of assigning a specific set of permissions to each individual user. Instead, you can assign specific permissions to a group and then add IAM users to that group. All the users in a group will have similar access.&lt;/p&gt;

&lt;p&gt;For example, you can consider creating different groups for various teams within your organization like Admins, Developers, Testers, etc. You can then assign specific permissions to these groups. Whenever a new user is onboarded, you can assign the user to a group, and then the user will have all the permissions assigned to that group. You can add the same user to multiple groups. By default, when you create your AWS account, there are no groups created. You need to create groups on your own according to your requirements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--t887ZvXo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h5p6nmxp4jal8kg898y6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--t887ZvXo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h5p6nmxp4jal8kg898y6.png" alt="Figure 4 – Overview of Groups and Users in AWS" width="880" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Policies
&lt;/h2&gt;

&lt;p&gt;So far, we have learned about IAM users and groups in AWS, but we did not understand how to allow or deny access to the users or groups. This is specifically done using policies. Policies in IAM are objects that can be assigned to users or groups and control their access to the resources on AWS. Whenever a user requests a specific resource, these policies are evaluated while the request is made. If the policy allows access, then the user or the group will be able to access the specific resource as requested.&lt;/p&gt;

&lt;p&gt;There are quite a few types of IAM policies of which the following two are the most important ones.&lt;/p&gt;

&lt;p&gt;Identity-based policies – These policies are attached to IAM users or IAM roles (we will see them later in the article). It defines to which resources the IAM user has been granted or rejected access toResource-based policies – These policies are attached to specific resources on AWS to define how they can interact with other resources within the AWS environment. These are used to define delegated permissions for resources like EC2 to have access to an S3 bucket within the same AWS account&lt;/p&gt;

&lt;p&gt;A policy in AWS is defined using JSON and looks something like the below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mTt5_lqi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ep184jqpmpfjdlhqs7we.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mTt5_lqi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ep184jqpmpfjdlhqs7we.png" alt="Figure 5 – AWS Policy for Administrator Role" width="880" height="611"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the figure above, the JSON statement defines the administrator policy in the AWS account. There are a few components of the policy JSON statement like version, an array of statements, and each of the statements can have an effect, action, and a resource specified.&lt;/p&gt;

&lt;p&gt;Version – It is used to specify the version of the policy language. For most of the cases, you will be using the default and latest version 2012-10-07Statement – Used to define the policy for a specific element. A policy can have one or more statementsEffect – Defines whether you want to allow or deny accessAction – Defines from a list of actions that can be performed on a resourceResource – The IAM ARN of the resource on which the permission is being granted&lt;/p&gt;

&lt;p&gt;You can read more about policies in detail from the official documentation. You can also customize your policies to allow more restricted access. For example, you can also define policies that allow access to resources only during specific hours of the day or only while using a Multi-Factor Authentication. These are complex topics and beyond the scope of this article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Roles
&lt;/h2&gt;

&lt;p&gt;IAM Roles are an important concept in AWS. You can think of roles as permissions, not for a user, instead of for an AWS service itself. In the previous sections of the article, we have seen what IAM users are and how to allow access to these users to specific resources in AWS. However, when an AWS resource needs to access contents within the AWS, then we cannot create a user for the user. In such cases, we create roles with policies and then allow the AWS resource to assume the role while making the requests.&lt;/p&gt;

&lt;p&gt;You can consider a scenario where an EC2 instance might want to read data from an S3 bucket. Here, we can create a role that has FullS3Access and then allow the EC2 instance to assume the role.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, we have understood the concept of AWS IAM. It is one of the most important services that need to be correctly set up for any organization before the development and other activities are initiated. There are also a few best practices suggested by Amazon that should be followed while designing the IAM structures. As already mentioned in the article, there are two ways of accessing resources on AWS, either by a username and password or by using secret access keys. You should also keep an active eye on and monitor the activities within your AWS Account. You can read more about monitoring activities from the official documentation.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>iam</category>
      <category>user</category>
      <category>roles</category>
    </item>
    <item>
      <title>Use Cloud Formation Templates to spin up MySQL instances on RDS</title>
      <dc:creator>Aveek Das</dc:creator>
      <pubDate>Tue, 22 Mar 2022 08:27:05 +0000</pubDate>
      <link>https://forem.com/aveekd22/use-cloud-formation-templates-to-spin-up-mysql-instances-on-rds-17d7</link>
      <guid>https://forem.com/aveekd22/use-cloud-formation-templates-to-spin-up-mysql-instances-on-rds-17d7</guid>
      <description>&lt;p&gt;In this article, I am going to discuss how to set up a MySQL instance on AWS RDS using Cloud Formation templates. In my previous article, &lt;a href="https://www.sqlshack.com/how-to-configure-amazon-rds-mysql-environment/"&gt;How to configure an Amazon RDS environment for MySQL&lt;/a&gt;, I have provided a detailed walkthrough of how to set up a MySQL instance on Amazon. You can use the AWS console to provide all the information required for setting up the instance and then use it. However, in this article, we will discuss an automated way of achieving the same functionalities using Cloud Formation templates.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a CloudFormation template?
&lt;/h2&gt;

&lt;p&gt;In order to start writing the templates, we first need to understand what cloud formation is all about. AWS offers Cloud Formation as a cloud service that enables AWS customers to write the desired state of any infrastructure as a code and then use it to deploy resources to AWS. It allows us to create a resource or a group of resources by following simple configuration templates. For example, if you want to deploy a web application on an EC2 instance that will also use an RDS database, you can simply combine both the resources into one stack and write the code for setting up the instances. Once you run, it will create both the EC2 and the RDS instance and also deploy your web application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--go3O56Q0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/cloudformation-template-on-aws-console.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--go3O56Q0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/cloudformation-template-on-aws-console.png" alt="*Figure 1 – CloudFormation Template on AWS Console*" width="880" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 1 – CloudFormation Template on AWS Console&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The components of a cloud formation template are as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;JSON&lt;/strong&gt; or &lt;strong&gt;YAML&lt;/strong&gt; file in which the resources will be defined as a template&lt;/li&gt;
&lt;li&gt;A stack can be a combination of multiple resources that needed to be set up as a part of the application. For e.g., EC2 and RDS&lt;/li&gt;
&lt;li&gt;A changeset can be used to view a list of operations to be performed by the stack&lt;/li&gt;
&lt;li&gt;A stack set also can be considered as a managed group of stacks that be reproduced or replicated&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Out of the above, we will mainly focus on the JSON/YAML template and the stack in this article. The templates support a wide range of resources on AWS. To get an exhaustive list please follow this &lt;a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html"&gt;link&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing the JSON or YAML template file
&lt;/h2&gt;

&lt;p&gt;One of the main challenges that we face while writing a template for the first time is what contents should be included in it. To ease that AWS provides a lot of &lt;a href="https://aws.amazon.com/cloudformation/resources/templates/"&gt;template samples&lt;/a&gt; that can be easily found on the official documentation. Once you find the template required to create a necessary resource, you can use it to create your own template. The template can either be created using JSON or YAML and converted from one to another as well. On a personal note, I prefer writing the templates using YAML as it helps me keep away from the curly braces and commas and keeps the document cleaner. However, you are free to choose any option between JSON and YAML.&lt;/p&gt;

&lt;p&gt;For this exercise, let us try to spin up a MySQL instance on RDS and we will write the code in YAML. In order to set up a MySQL database using cloud formation, we would need the following items.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Resource Name&lt;/strong&gt; – The name of the resource you are going to set up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource Type&lt;/strong&gt; – The type of the resource.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource Properties&lt;/strong&gt; – The database name, username, and password to connect to.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The database Engine&lt;/strong&gt; – MySQL, SQL Server, PostgreSQL, etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage Type&lt;/strong&gt; – The storage type to be used.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public Accessibility&lt;/strong&gt; – Weather the database should have public access or not.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Allocated Memory&lt;/strong&gt; – The memory that should be allocated to the database instance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Region&lt;/strong&gt; – The region in which the instance is to be created.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that we have some points with us, let us go ahead and start by writing the template file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/aveek22/a188b02abde65479bbba2deba5ec90d6"&gt;https://gist.github.com/aveek22/a188b02abde65479bbba2deba5ec90d6&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mAeJwrey--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/the-template-file-for-creating-mysql-instance-on-r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mAeJwrey--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/the-template-file-for-creating-mysql-instance-on-r.png" alt="*Figure 2 – The template file for creating MySQL instance on RDS*" width="880" height="594"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2 – The template file for creating MySQL instance on RDS&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the figure above, the structure of the file is divided into two parts. In the first part, we have defined a few parameters that will be used by the resource definitions in the second part while creating the resources on AWS. You can use the same script on your machine to create an instance on your AWS account.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up the stack on the console
&lt;/h2&gt;

&lt;p&gt;Now that we have created our template for MySQL, it’s time we set it up to see if everything runs well. Head over to the AWS console and search for Cloud Formation on the search bar. Click on Create Stack and upload the template file from your local. Click &lt;strong&gt;Next&lt;/strong&gt; once done.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LVD7zlVE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/creating-the-stack-from-template.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LVD7zlVE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/creating-the-stack-from-template.png" alt="*Figure 3 – Creating the stack from the template*" width="880" height="439"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 3 – Creating the stack from the template&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On the next page, you will be asked to provide the parameters that were defined in the cloud formation template. Go ahead and provide the necessary details and click &lt;strong&gt;Next&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wVtyfdQc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/stack-parameters-provided.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wVtyfdQc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/stack-parameters-provided.png" alt="*Figure 4 – Stack Parameters provided*" width="880" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 4 – Stack Parameters provided&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Review the stack changes and parameters and click on &lt;strong&gt;Create Stack&lt;/strong&gt; on the last page. The stack creation will start. It might take some time to create all the resources before they are available to use. In the meantime, you can click on the Reload button to check if all the events have been created successfully.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gS3Qmln5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/stack-creation-in-progress.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gS3Qmln5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/stack-creation-in-progress.png" alt="*Figure 5 – Stack Creation in progress*" width="880" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 5 – Stack Creation in progress&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As you can see on the timestamps, it took me around 6 minutes after which the resources were available and were also visible on the console. Navigate to the &lt;strong&gt;Resources&lt;/strong&gt; tab and click on the &lt;strong&gt;Physical ID&lt;/strong&gt; of the resource. This will take you to the RDS console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TsSlbpEL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/stack-created-successfully.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TsSlbpEL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/stack-created-successfully.png" alt="*Figure 6 – Stack Created Successfully*" width="880" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 6 – Stack Created Successfully&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting the MySQL database
&lt;/h2&gt;

&lt;p&gt;Once you are in the RDS console, you can get the hostname for the database instance and use it to connect to the database. Grab the &lt;strong&gt;endpoint&lt;/strong&gt; from the console and use it to connect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1X2Pyaes--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/mysql-instance-details-on-rds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1X2Pyaes--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/mysql-instance-details-on-rds.png" alt="*Figure 7 – MySQL instance details on RDS*" width="880" height="530"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 7 – MySQL instance details on RDS&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let us now head over to MySQL Workbench and try connecting to the hostname with the credentials that we have provided earlier. Use the hostname, username, and password to connect to the instance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8OpXHAo9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/connecting-to-the-mysql-instance-using-mysql-workb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8OpXHAo9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/connecting-to-the-mysql-instance-using-mysql-workb.png" alt="*Figure 8 – Connecting to the MySQL instance using MySQL Workbench*" width="880" height="598"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 8 – Connecting to the MySQL instance using MySQL Workbench&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the figure above, we have successfully connected to the database instance on RDS. Let us now run some queries and see if it works.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--44asa713--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/executing-scripts-in-the-mysql-workbench.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--44asa713--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/executing-scripts-in-the-mysql-workbench.png" alt="*Figure 9 – Executing scripts in the MySQL Workbench*" width="880" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 9 – Executing scripts in the MySQL Workbench&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the figure above, we have been able to connect to the database instance and execute queries. With this, you are able to write your own cloud formation template and spin up any other resources like the SQL Server or PostgreSQL database. &lt;/p&gt;

&lt;h2&gt;
  
  
  Removing the resources
&lt;/h2&gt;

&lt;p&gt;If you are performing this as an exercise, I would recommend removing the resources that we have created as it will incur some charges. You can navigate to the RDS console and then select the instance and click on &lt;strong&gt;Delete&lt;/strong&gt; to remove the resources permanently.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FblbbPbT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/deleting-the-resources-created.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FblbbPbT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.sqlshack.com/wp-content/uploads/2021/04/deleting-the-resources-created.png" alt="*Figure 10 – Deleting the resources created*" width="880" height="690"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 10 – Deleting the resources created&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Once the resources have been deleted successfully, you can check in the console once again if there are any instances running just to avoid adding unnecessary billing costs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, we have discussed in detail how to set up a MySQL database instance in an AWS RDS environment and automate it using the Cloud Formation template. This way if setting up resources on the cloud is also known as infrastructure-as-code service where you can set up the entire infrastructure as code and then use it in various environments. These templates can be used not only to deploy database instances but also other infrastructures within the AWS such as EC2, Lambda, RedShift, etc. To learn more about the cloud formation templates, you can view the sample templates available on the &lt;a href="https://aws.amazon.com/cloudformation/resources/templates/"&gt;official website&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>mysql</category>
      <category>cloudformation</category>
      <category>rds</category>
    </item>
    <item>
      <title>An introduction to sharing content on LinkedIn using REST APIs and Python</title>
      <dc:creator>Aveek Das</dc:creator>
      <pubDate>Mon, 14 Mar 2022 11:02:34 +0000</pubDate>
      <link>https://forem.com/aveekd22/an-introduction-to-sharing-content-on-linkedin-using-rest-apis-and-python-9fh</link>
      <guid>https://forem.com/aveekd22/an-introduction-to-sharing-content-on-linkedin-using-rest-apis-and-python-9fh</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/"&gt;LinkedIn&lt;/a&gt; is a popular social media platform that allows users to connect to each other and maintain professional network. You can manage your profile and also create a company profile for your organization. An interesting feature of LinkedIn is the ability to share posts on your feed or on your organization’s feed. You can embed URLs, provide hashtags and emojis and also share images and videos in your post. Although the primary way of sharing content on LinkedIn is by using the web application, you can also do it programmatically using the &lt;a href="https://docs.microsoft.com/en-us/linkedin/"&gt;REST APIs&lt;/a&gt; provided by LinkedIn and a programming language of your choice.&lt;/p&gt;

&lt;p&gt;In this article, we are going to learn how to use the &lt;a href="https://docs.microsoft.com/en-us/linkedin/"&gt;LinkedIn REST APIs&lt;/a&gt; and share content from your personal profile as well as from an organization’s profile that you manage. Don’t worry if you do not have an organization as I will guide you from the scratch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-requisites
&lt;/h2&gt;

&lt;p&gt;In order to proceed further, we need to have the following pre-requisites.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;LinkedIn Account&lt;/strong&gt; – You need to have a LinkedIn account, if you do not have one, please head over to &lt;a href="https://www.linkedin.com/"&gt;https://www.linkedin.com/&lt;/a&gt; and create one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;REST APIs&lt;/strong&gt; – Some basic knowledge of using REST APIs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Python&lt;/strong&gt; – General programming knowledge of using python and using REST APIs in python.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Apart from the above-mentioned, I am going to use Jupyter notebooks to create the codebase and make it available using GitHub. At any point in time, you can choose to refer to the official documentation of LinkedIn from Microsoft, however, I will try to explain the process in simple terms.&lt;/p&gt;

&lt;h1&gt;
  
  
  Creating the LinkedIn Company Page and Application
&lt;/h1&gt;

&lt;p&gt;Assuming that you already have your LinkedIn account created, now we will create the following two assets.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://business.linkedin.com/marketing-solutions/linkedin-pages"&gt;LinkedIn Company Page&lt;/a&gt; – Also, can be referred to as the Company page, we need to create it using your personal account. You will be an admin for the Company page that you create.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.linkedin.com/"&gt;An Application on the Developers portal&lt;/a&gt; – In order to get access to the LinkedIn REST APIs, we need to create an application, that will assume the permissions on our behalf and share content on your profile or from the organisation’s profile.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Create the LinkedIn Company Page.
&lt;/h2&gt;

&lt;p&gt;Let’s create a company page from your LinkedIn account. You can think of any dummy name for your company to proceed forward. I am going to use my company as “&lt;em&gt;DataScholar&lt;/em&gt;”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Step 1&lt;/em&gt;&lt;/strong&gt;: Open LinkedIn account. Click on &lt;strong&gt;Work&lt;/strong&gt; and select &lt;strong&gt;Create a Company Page&lt;/strong&gt;. Click on &lt;strong&gt;Company&lt;/strong&gt; and enter the details and click on &lt;strong&gt;Create Page&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jc_RKUyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled.png%3Fresize%3D1024%252C411%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jc_RKUyE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled.png%3Fresize%3D1024%252C411%26ssl%3D1" alt="Figure 1 – Create LinkedIn company page" width="880" height="353"&gt;&lt;/a&gt;Figure 1 – Create LinkedIn company page&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Step 2&lt;/em&gt;&lt;/strong&gt;: You need to provide the following details for your company page to be created.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Name&lt;/strong&gt; – The name of your company. I am using &lt;em&gt;DataScholar&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Company&lt;/strong&gt; &lt;strong&gt;URL&lt;/strong&gt; – The LinkedIn username of your company.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Website&lt;/strong&gt; – The website your company is hosted on. I am going to use “&lt;em&gt;&lt;a href="https://thedatascholar.com"&gt;https://thedatascholar.com&lt;/a&gt;&lt;/em&gt;”.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Industry&lt;/strong&gt; – Select as &lt;em&gt;Software&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Company&lt;/strong&gt; &lt;strong&gt;Size&lt;/strong&gt; – I have selected &lt;em&gt;between 0 and 1&lt;/em&gt; since I am the sole user of the company.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Company&lt;/strong&gt; &lt;strong&gt;Type&lt;/strong&gt; – &lt;em&gt;Non-profit&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logo&lt;/strong&gt; – Any custom image for your company logo.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tagline&lt;/strong&gt; – A short description of your company.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once you have provided all these details, your LinkedIn company page has been created now.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c2qHWNNA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-1.png%3Fresize%3D1024%252C606%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c2qHWNNA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-1.png%3Fresize%3D1024%252C606%26ssl%3D1" alt="" width="880" height="521"&gt;&lt;/a&gt;Figure 2 – LinkedIn company page&lt;/p&gt;

&lt;h2&gt;
  
  
  Create the LinkedIn app in the Developer Portal.
&lt;/h2&gt;

&lt;p&gt;In this section, we will dig a bit deeper and create an application on LinkedIn Developer’s platform that will allow us to interact with the LinkedIn assets programmatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Step 1&lt;/em&gt;&lt;/strong&gt;: Navigate to &lt;a href="https://developer.linkedin.com/"&gt;https://developer.linkedin.com/&lt;/a&gt;. Click on &lt;strong&gt;My Apps&lt;/strong&gt; and then select &lt;strong&gt;Create App&lt;/strong&gt;. Enter the details for your application.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;App Name&lt;/strong&gt; – The name for your application. You can use the same name as your company.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LinkedIn Page&lt;/strong&gt; – The company page that the app will be associated with.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privacy Policy URL&lt;/strong&gt; – Optional field.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;App Logo&lt;/strong&gt; – Upload a logo for your app.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Agree to the terms and then click on &lt;strong&gt;Create App&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--42UWrEV4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-2.png%3Fresize%3D1024%252C506%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--42UWrEV4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-2.png%3Fresize%3D1024%252C506%26ssl%3D1" alt="" width="880" height="435"&gt;&lt;/a&gt;Figure 3 – Creating LinkedIn App&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Step 2&lt;/em&gt;&lt;/strong&gt;: Click &lt;strong&gt;Verify&lt;/strong&gt; to verify your application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Haeor6dj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-3.png%3Fresize%3D1024%252C506%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Haeor6dj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-3.png%3Fresize%3D1024%252C506%26ssl%3D1" alt="" width="880" height="435"&gt;&lt;/a&gt;Figure 4 – Verify LinkedIn application&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Step 3&lt;/em&gt;&lt;/strong&gt;: Click &lt;strong&gt;Generate URL&lt;/strong&gt; and copy the URL and click &lt;strong&gt;I’m Done&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6lPJBzk3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-4-1.png%3Fresize%3D1024%252C506%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6lPJBzk3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-4-1.png%3Fresize%3D1024%252C506%26ssl%3D1" alt="" width="880" height="435"&gt;&lt;/a&gt;Figure 5 – Generate verification URL for the LinkedIn app&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Step 4&lt;/em&gt;&lt;/strong&gt;: Copy and hit the URL on the browser. It will ask you to verify the app for the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ueB6eUBo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-5-1.png%3Fresize%3D1024%252C506%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ueB6eUBo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-5-1.png%3Fresize%3D1024%252C506%26ssl%3D1" alt="" width="880" height="435"&gt;&lt;/a&gt;Figure 6 – Verify LinkedIn app and Company association&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Step 5&lt;/em&gt;&lt;/strong&gt;: Click on &lt;strong&gt;Verify&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KiQibpL7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-6.png%3Fresize%3D1024%252C506%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KiQibpL7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-6.png%3Fresize%3D1024%252C506%26ssl%3D1" alt="" width="880" height="435"&gt;&lt;/a&gt;Figure 7- LinkedIn app and Company association verified&lt;br&gt;
Great! You have now successfully created a LinkedIn company page and also created an app to interact with LinkedIn using the REST APIs.&lt;/p&gt;
&lt;h1&gt;
  
  
  Configure your LinkedIn App
&lt;/h1&gt;

&lt;p&gt;Let’s configure the LinkedIn app that we have created in the previous section. We will add the products required to access the LinkedIn REST APIs and store the app credentials.&lt;/p&gt;
&lt;h2&gt;
  
  
  Add the products for your LinkedIn App.
&lt;/h2&gt;

&lt;p&gt;Once you have created the LinkedIn App, you need to define what are the products that you are going to use with your app. Based on this, your app will be provided with the necessary permissions that you need. There are three products available to choose from.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Share on LinkedIn&lt;/strong&gt; – This allows you to post content from your profile.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sign In with LinkedIn&lt;/strong&gt; – This allows you to use LinkedIn social sign on your webpage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Marketing Developer Platform&lt;/strong&gt; – Allows you to post content from your page.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As a part of this article, I am going to add all three products to my app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6c2ioqK3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-7.png%3Fresize%3D1024%252C506%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6c2ioqK3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-7.png%3Fresize%3D1024%252C506%26ssl%3D1" alt="" width="880" height="435"&gt;&lt;/a&gt;Figure 8 – Add products to LinkedIn app&lt;br&gt;
The &lt;strong&gt;Marketing Developer Platform&lt;/strong&gt; requires additional access. You will receive a form for this. Fill up the form and wait for approval (2 business days). Click on the &lt;strong&gt;View Access Form&lt;/strong&gt; and fill it up with relevant details.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UMViKu0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-8.png%3Fresize%3D1024%252C561%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UMViKu0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-8.png%3Fresize%3D1024%252C561%26ssl%3D1" alt="" width="880" height="482"&gt;&lt;/a&gt;Figure 9 – Fill up review form for Marketing Developer Platform&lt;br&gt;
Once you submit the form, it might take up to 2 business days to get an answer by email. You will then notice the app has been added to your product list.&lt;/p&gt;

&lt;p&gt;💡 The &lt;strong&gt;&lt;em&gt;Marketing Developer Platform&lt;/em&gt;&lt;/strong&gt; allows you to post content from your company page. Without adding it, you can still post content from your personal LinkedIn profile.&lt;/p&gt;
&lt;h2&gt;
  
  
  Fetch and store the app credentials.
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Step 1&lt;/em&gt;&lt;/strong&gt;: On your LinkedIn app, click on the &lt;strong&gt;Auth&lt;/strong&gt; tab. You can find the &lt;strong&gt;Client ID&lt;/strong&gt; and &lt;strong&gt;Client Secret&lt;/strong&gt; that you need later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pMmHc4yp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-9.png%3Fresize%3D1024%252C506%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pMmHc4yp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-9.png%3Fresize%3D1024%252C506%26ssl%3D1" alt="" width="880" height="435"&gt;&lt;/a&gt;Figure 10 – Store LinkedIn app credentials&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Step 2&lt;/em&gt;&lt;/strong&gt;: Add the redirect URL for your App. This can simply be your webpage URL appended with “&lt;em&gt;/auth/linkedin/callback&lt;/em&gt;”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mHHN11KT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-10.png%3Fresize%3D1024%252C561%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mHHN11KT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-10.png%3Fresize%3D1024%252C561%26ssl%3D1" alt="" width="880" height="482"&gt;&lt;/a&gt;Figure 11 – Setup app Redirect URI&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Step 3&lt;/em&gt;&lt;/strong&gt;: Get the &lt;strong&gt;Organization ID&lt;/strong&gt; from the company URL.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uAnFsxnj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-11.png%3Fresize%3D912%252C68%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uAnFsxnj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-11.png%3Fresize%3D912%252C68%26ssl%3D1" alt="" width="880" height="66"&gt;&lt;/a&gt;Figure 12 – Get Organization ID&lt;/p&gt;
&lt;h1&gt;
  
  
  Start assembling your Python code
&lt;/h1&gt;

&lt;p&gt;Now let’s start building the python program that would allow us to interact with the LinkedIn REST APIs.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup static variables and libraries
&lt;/h2&gt;

&lt;p&gt;In order to work with REST APIs in python, we will leverage the &lt;code&gt;requests&lt;/code&gt; library. You can install it using the python &lt;code&gt;pip&lt;/code&gt; manager. In addition to that, we will also create variables to store our &lt;code&gt;client_id&lt;/code&gt;, &lt;code&gt;client_secret&lt;/code&gt;, and &lt;code&gt;organization_id&lt;/code&gt; that we have obtained in the previous section.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;In the next steps, we need to get an Access Token that can be used to share content from the LinkedIn profile. The Access Token can be obtained in two steps as follows.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A &lt;strong&gt;GET&lt;/strong&gt; request that will ask the user to allow your app to obtain the required permissions and redirect you to a new URL. From this URL, you’ll need to extract the value in the parameter code.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;POST&lt;/strong&gt; request that will return your brand new Access Token.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Create the GET request to obtain verification code
&lt;/h2&gt;

&lt;p&gt;Setup the following details to build the URL.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;base_url&lt;/code&gt;: The LinkedIn endpoint to obtain authorization code.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;redirect_uri&lt;/code&gt;: The redirect URL you have set while creating your app.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;scope&lt;/code&gt;: The scope required to publish content from your personal profile.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;state&lt;/code&gt;: A random text that will be returned to you after authorization. This allows you to verify the response from CSRF attacks. For simplicity, let’s not bother much about it now.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;.gist table { margin-bottom: 0; }&lt;/p&gt;

&lt;p&gt;This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.&lt;br&gt;
 &lt;a href="https://github.co/hiddenchars"&gt;Learn more about bidirectional Unicode characters&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to%7B%7B%20revealButtonHref%20%7D%7D"&gt;Show hidden characters&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;base_url = "&lt;a href="https://www.linkedin.com/oauth/v2/authorization&amp;amp;quot"&gt;https://www.linkedin.com/oauth/v2/authorization&amp;amp;quot&lt;/a&gt;;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;redirect_uri = "&lt;a href="https://thedatascholar.com/auth/linkedin/callback&amp;amp;quot"&gt;https://thedatascholar.com/auth/linkedin/callback&amp;amp;quot&lt;/a&gt;;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;scope = "w_member_social,r_liteprofile"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;url = f"{base_url}?response_type=code&amp;amp;client_id={client_id}&amp;amp;state=random&amp;amp;redirect_uri={redirect_uri}&amp;amp;scope={scope}"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;print(url)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/aveek22/8978355f31b779cc8cd2b6d844bf9d34/raw/0e906ad72da0c40e5cdb0350023360cf299eaa94/social_linkedin_auth.py"&gt;view raw&lt;/a&gt;&lt;br&gt;
&lt;a href="https://gist.github.com/aveek22/8978355f31b779cc8cd2b6d844bf9d34#file-social_linkedin_auth-py"&gt;social_linkedin_auth.py&lt;/a&gt; &lt;br&gt;
 hosted with ❤ by &lt;a href="https://github.com"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you run the above code, it will print the URL on your console. Copy the URL and hit it in your browser. You will be asked to log in with your LinkedIn credentials. Once your login is verified, it will redirect you to the address mentioned in the &lt;code&gt;redirect_uri&lt;/code&gt;. You will also receive two parameters, &lt;code&gt;code&lt;/code&gt;, and &lt;code&gt;state&lt;/code&gt; in this URL. Copy the value of the &lt;code&gt;code&lt;/code&gt; and store it for processing the next request.&lt;/p&gt;

&lt;p&gt;💡 To publish content from your company page, you need more permissions in your scope. This can be obtained once you have received verification for the &lt;strong&gt;Marketing Developer Platform&lt;/strong&gt; from the LinkedIn team.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create the POST request to obtain the Access Token
&lt;/h2&gt;

&lt;p&gt;Now that the verification code has been obtained, we can get the access token by sending a POST request to LinkedIn. You need to provide the following as a payload in the POST request.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;grant_type&lt;/code&gt;: The grant type should be ‘&lt;em&gt;authorization_code&lt;/em&gt;’.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;code&lt;/code&gt;: The authorization code obtained in the previous step.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;redirect_uri&lt;/code&gt;: The redirect URI of your app.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;client_id&lt;/code&gt;: The client ID that we stored earlier.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;client_secret&lt;/code&gt;: The client secret that we stored earlier.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;.gist table { margin-bottom: 0; }&lt;/p&gt;

&lt;p&gt;This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.&lt;br&gt;
 &lt;a href="https://github.co/hiddenchars"&gt;Learn more about bidirectional Unicode characters&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to%7B%7B%20revealButtonHref%20%7D%7D"&gt;Show hidden characters&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;url_access_token = "&lt;a href="https://www.linkedin.com/oauth/v2/accessToken&amp;amp;quot"&gt;https://www.linkedin.com/oauth/v2/accessToken&amp;amp;quot&lt;/a&gt;;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;auth_code = "YOUR_AUTH_CODE_FROM_PREVIOUS_VERIFICATION"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;payload = {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'grant_type' : 'authorization_code',&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'code' : auth_code,&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'redirect_uri' : redirect_uri,&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'client_id' : client_id,&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'client_secret' : client_secret&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;response = requests.post(url=url_access_token, params=payload)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;response_json = response.json()&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;# Extract the access_token from the response_json&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;access_token = response_json['access_token']&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/aveek22/253b85ff96e450d7171833e4dade52ad/raw/b548453262cb41de94e03136184b22169f9c9aae/social_linkedin_access_token.py"&gt;view raw&lt;/a&gt;&lt;br&gt;
&lt;a href="https://gist.github.com/aveek22/253b85ff96e450d7171833e4dade52ad#file-social_linkedin_access_token-py"&gt;social_linkedin_access_token.py&lt;/a&gt; &lt;br&gt;
 hosted with ❤ by &lt;a href="https://github.com"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the POST request is successful, you will receive a JSON response that will contain the &lt;code&gt;access_token&lt;/code&gt;. I have extracted and stored it in a separate variable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get your LinkedIn profile ID
&lt;/h2&gt;

&lt;p&gt;In order to post content from your LinkedIn profile, you need to obtain your profile ID. This can be done by querying the LinkedIn REST API directly.&lt;/p&gt;

&lt;p&gt;.gist table { margin-bottom: 0; }&lt;/p&gt;

&lt;p&gt;This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.&lt;br&gt;
 &lt;a href="https://github.co/hiddenchars"&gt;Learn more about bidirectional Unicode characters&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to%7B%7B%20revealButtonHref%20%7D%7D"&gt;Show hidden characters&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;# Get LinkedIn user ID&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;url = "&lt;a href="https://api.linkedin.com/v2/me&amp;amp;quot"&gt;https://api.linkedin.com/v2/me&amp;amp;quot&lt;/a&gt;;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;header = {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'Authorization' : f'Bearer {access_token}'&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;response = requests.get(url=url, headers=header)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;response_json_li_person = response.json()&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;person_id = response_json_li_person['id']&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/aveek22/de44ea0d5a0d322a0ce98c2e26ea4502/raw/6c478f3028fcd1f7a120388b8e41d12214029f9d/social_linkedin_profile.py"&gt;view raw&lt;/a&gt;&lt;br&gt;
&lt;a href="https://gist.github.com/aveek22/de44ea0d5a0d322a0ce98c2e26ea4502#file-social_linkedin_profile-py"&gt;social_linkedin_profile.py&lt;/a&gt; &lt;br&gt;
 hosted with ❤ by &lt;a href="https://github.com"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice that I have passed the &lt;code&gt;access_token&lt;/code&gt; as a bearer token in the authorization header. Also, I have stored the LinkedIn profile ID in a variable called &lt;code&gt;person_id&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Share content from LinkedIn Personal Profile
&lt;/h2&gt;

&lt;p&gt;Let’s prepare the content that we want to share from our LinkedIn personal profile. I have selected a random &lt;a href="https://www.redhat.com/en/topics/api/what-is-a-rest-api"&gt;article from Redhat&lt;/a&gt; that I would like to share. Also, I would like to add a thumbnail image to the content that is shared. For that, you can choose any image that is publicly available. Notice that the payload contains the key &lt;code&gt;owner&lt;/code&gt; and the value is the profile ID that we obtained in the earlier step. This value determines if the post is to be shared from the personal profile or from the company page.&lt;/p&gt;

&lt;p&gt;.gist table { margin-bottom: 0; }&lt;/p&gt;

&lt;p&gt;This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.&lt;br&gt;
 &lt;a href="https://github.co/hiddenchars"&gt;Learn more about bidirectional Unicode characters&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to%7B%7B%20revealButtonHref%20%7D%7D"&gt;Show hidden characters&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;url = "&lt;a href="https://api.linkedin.com/v2/shares&amp;amp;quot"&gt;https://api.linkedin.com/v2/shares&amp;amp;quot&lt;/a&gt;;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;headers = {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'Authorization' : f'Bearer {access_token}',&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'Content-Type' : 'application/json'&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;payload = {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;"content": {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;"contentEntities": [&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;{&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;"entityLocation": "&lt;a href="https://www.redhat.com/en/topics/api/what-is-a-rest-api&amp;amp;quot"&gt;https://www.redhat.com/en/topics/api/what-is-a-rest-api&amp;amp;quot&lt;/a&gt;;,&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;"thumbnails": [&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;{&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;"resolvedUrl": "&lt;a href="https://images.pexels.com/photos/2115217/pexels-photo-2115217.jpeg&amp;amp;quot"&gt;https://images.pexels.com/photos/2115217/pexels-photo-2115217.jpeg&amp;amp;quot&lt;/a&gt;;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;]&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;],&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;"title": "What is a REST API?"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;},&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'distribution': {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'linkedInDistributionTarget': {}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;},&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'owner': f'urn:li:person:{person_id}',&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'text': {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'text': f'Learn more about REST APIs in details. \n#restapi #api'&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;response = requests.post(url=url, headers=headers, json = payload)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;print(response.json())&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/aveek22/aa6f179dcd42bfb25caa7ea7cae09ec6/raw/64abc195a831f960f0227f6092bbad6873c86a33/social_linkedin_share_post_personal.py"&gt;view raw&lt;/a&gt;&lt;br&gt;
&lt;a href="https://gist.github.com/aveek22/aa6f179dcd42bfb25caa7ea7cae09ec6#file-social_linkedin_share_post_personal-py"&gt;social_linkedin_share_post_personal.py&lt;/a&gt; &lt;br&gt;
 hosted with ❤ by &lt;a href="https://github.com"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to understand the payload in more depth, please refer to the &lt;a href="https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api?tabs=http#post-shares"&gt;official documentation&lt;/a&gt;. There is a clear explanation of what each of the fields in the payload is about. Once the request is successful, the content will be shared from your personal profile and it will appear in the feed as follows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1WwL2JVW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-12.png%3Fresize%3D841%252C1024%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1WwL2JVW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-12.png%3Fresize%3D841%252C1024%26ssl%3D1" alt="" width="841" height="1024"&gt;&lt;/a&gt;Figure 13 – Post shared from the personal profile on LinkedIn&lt;/p&gt;

&lt;h2&gt;
  
  
  Share content from LinkedIn Company Page
&lt;/h2&gt;

&lt;p&gt;Sharing content from an organization’s page is almost similar to that of sharing from a personal profile. The only key that determines whether the post content is to be shared from a personal or organization’s profile is the &lt;code&gt;owner&lt;/code&gt;. The following values are accepted for the &lt;code&gt;owner&lt;/code&gt; key.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Personal Profile&lt;/strong&gt;: &lt;code&gt;urn:li:person:{person_id}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Organization&lt;/strong&gt;: &lt;code&gt;urn:li:organization:{organization_id}&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can fetch the organization_id from the URL of your company page. With that, now the payload can be modified and content shared from the organization’s profile.&lt;/p&gt;

&lt;p&gt;.gist table { margin-bottom: 0; }&lt;/p&gt;

&lt;p&gt;This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.&lt;br&gt;
 &lt;a href="https://github.co/hiddenchars"&gt;Learn more about bidirectional Unicode characters&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to%7B%7B%20revealButtonHref%20%7D%7D"&gt;Show hidden characters&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;url = "&lt;a href="https://api.linkedin.com/v2/shares&amp;amp;quot"&gt;https://api.linkedin.com/v2/shares&amp;amp;quot&lt;/a&gt;;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;headers = {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'Authorization' : f'Bearer {access_token}',&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'Content-Type' : 'application/json'&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;payload = {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;"content": {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;"contentEntities": [&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;{&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;"entityLocation": "&lt;a href="https://www.redhat.com/en/topics/api/what-is-a-rest-api&amp;amp;quot"&gt;https://www.redhat.com/en/topics/api/what-is-a-rest-api&amp;amp;quot&lt;/a&gt;;,&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;"thumbnails": [&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;{&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;"resolvedUrl": "&lt;a href="https://images.pexels.com/photos/2115217/pexels-photo-2115217.jpeg&amp;amp;quot"&gt;https://images.pexels.com/photos/2115217/pexels-photo-2115217.jpeg&amp;amp;quot&lt;/a&gt;;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;]&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;],&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;"title": "What is a REST API?"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;},&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'distribution': {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'linkedInDistributionTarget': {}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;},&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'owner': f'urn:li:organization:{organization_id}',&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'text': {&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;'text': f'Learn more about REST APIs in details. \n#restapi #api'&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;}&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;response = requests.post(url=url, headers=headers, json = payload)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;print(response.json())&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/aveek22/651ce87c660ebee304b78dbd85713343/raw/a360f2f6cab61ffa847998ad86a9640e93248861/social_linkedin_share_post_organization.py"&gt;view raw&lt;/a&gt;&lt;br&gt;
&lt;a href="https://gist.github.com/aveek22/651ce87c660ebee304b78dbd85713343#file-social_linkedin_share_post_organization-py"&gt;social_linkedin_share_post_organization.py&lt;/a&gt; &lt;br&gt;
 hosted with ❤ by &lt;a href="https://github.com"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will post the content from your organization’s profile and you will have it on your feed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4JzAtAQG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-13.png%3Fresize%3D888%252C1024%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4JzAtAQG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i0.wp.com/datacloudmag.com/wp-content/uploads/2022/03/Untitled-13.png%3Fresize%3D888%252C1024%26ssl%3D1" alt="" width="880" height="1015"&gt;&lt;/a&gt;Figure 14 – Post shared from organization’s profile on LinkedIn&lt;br&gt;
💡 To post content from the organization’s profile, you need to wait until you have received the email from LinkedIn which might take 2 business days.&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;In this article, we have focused on how to use the LinkedIn REST APIs and share content from a personal profile as well as from an organization’s profile. This is just a beginner level introduction to using the LinkedIn REST APIs. Apart from sharing content, you can also use other &lt;a href="https://developer.linkedin.com/product-catalog"&gt;products&lt;/a&gt; to interact with LinkedIn Ads, and Campaign Management Tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;If you want to learn more about LinkedIn REST APIs, I would recommend reading through the following.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/linkedin/shared/authentication/authentication"&gt;https://docs.microsoft.com/en-us/linkedin/shared/authentication/authentication&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api"&gt;https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.linkedin.com/product-catalog"&gt;https://developer.linkedin.com/product-catalog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>rest</category>
      <category>api</category>
    </item>
  </channel>
</rss>
