API Integration for Business
How to integrate Ayrshare's API for multiple users.
An important part of the Business Plan integration consists of creating new profile accounts in Ayrshare for your users or clients and allowing your users to link their social networks. Each of your users is set up as an Ayrshare user profile. A user profile gets one connection to each social network.
Account Linking Workflow
After your user links their social media accounts you will be able to post to and manage their accounts via the API.
During your onboarding as a Business Plan client, you'll receive a personalized integration package with important set up and domain information, example endpoint calls, and more. Please check with your primary account holder for this information.
Returned from this call will be your user's PROFILE KEY. This key will be used to post on your user's behalf and to mange their account. You should store it in a secure location.
If you want to create client profiles via the Developer Dashboard see the overview:
Ayrshare uses a JWT (JSON Web Token) to authenticate your user and perform Single Sign On to the social accounts linkage page. A JWT is a secure mechanism for passing digitally signed information and allows Ayrshare to authenticate you and your user.
Your app will construct a JWT comprised of your API Key, user Profile Key, and a few other parameters. This will be signed with your 1024 bit private key. The JWT token is valid for 5 minutes.
Your app will construct a JWT comprised of your API Key, user Profile Key, and a few other parameters. This will be signed with your 1024 bit private key.
Alternatively, if you have your client's social media credentials (username/password) you can link their social network yourself using Ayrshare's Developer Dashboard.
tokenis passed as a URL parameter. From your app open in a new tab:
https://profile.ayrshare.com?domain=[domain id]&jwt=[jwt token]
domain idis your domain identified (provided to you by Ayrshare during setup) and
jwt tokenis the token created above. This is often done from a button or link on your site.
Your client will be single signed on into the Ayrshare app and be brought to the Social Media Accounts set up page.
How to Automatically Logout of the Active Profile Session
If a profile is already logged in, sending a different profile's JWT will not switch profiles. This is done to make the experience faster for already logged in users. When testing, log out of the current profile before making an SSO call with a different profile. Signed in profiles remain signed in until explicitly logged out.
However, if you have a business need, such as your users have multiple profiles they often access, or you want to test, include the URL parameter in the SSO URL:
https://profile.ayrshare.com?domain=[domain id]&jwt=[jwt token]&logout=true
This forces a logout and then logs in the new profile.
Warning: Using automatic logout causes a performance delay for your user, so unless you need it, we suggest not forcing a logout and not using it in production.
The Social Accounts page has an "All Done" button that closes the window and returns your user to your site.
<div onclick="window.open('https://profile.ayrshare.com?domain...', '_blank')">
Link Social Networks
Additionally, if you want to have the Done button redirect back to your page (often useful on mobile), pass in the
redirectGET parameter as a URL encoded string starting with https.
https://profile.ayrshare.com?domain=[domain id]&jwt=[jwt token]&redirect=https%3A%2F%2Fmywebsite.com
The redirect will be saved for that profile and used in subsequent SSO calls even if the
redirectparameter is not passed. To reset the Done button back to close, pass the parameter
Please see here for more details of the user experience:
Once your user setups their social media links, you will be able to begin posting on their behalf using the /post and /profile endpoints.
If your users or clients have multiple sets of social accounts, for example 2 Facebook, 2 Instagram, and 2 YouTube, you can create two User Profiles in Ayrshare and then associate the two Profile Keys with the user in your system.