##Prerequisites
-
- accounts.freedom.tm must recognize your service, and should be listed in its database.
-
- Aside from service recognition, you must have valid redirect URIs in your app.
##Authentication procedure flow from third party app(In javascript)
-
- Redirect to api.accounts.freedom.tm/auth with the following Parameters.
- a.) service - the service name.
- b.) redirect_uri - URL to redirect back to your app on login
- c.) response_type - The type of response needed (e.g. code)
- d.) roles - Roles requested (email, admin, profile)
In code, you may have something like :
<a href="http://api.accounts.freedom.tm/auth?service=earnings&redirect_uri=http://dev.earnings.tm:3000/profiler&reponse_type=code&roles=profile,email,partner"> Log In With Freedom </a>
Or even :
res.redirect('http://api.accounts.freedom.tm/auth?service=earnings&redirect_uri=http://dev.earnings.tm:3000/profiler&reponse_type=code&roles=profile,email,partner');
-
- The next important step is to prepare the redirect URI. It should be able to handle a get request, and it will have the access token alongside it.
Controller
import * as cudl from 'cuddle'; //import a cURL library
//receives get request as according to defined routes.
export freedom_callback = (req, res, next) => {
let access_token = req.query.access_token; //REMEMBER TO GET THE ACCESS TOKEN.
};
-
- Basically do whatever is needed to be done with the access token.
For example, you can use this access token to actually grab the user profile of its owner.
curl -H '"Access-Token" : "a6we3-mj7Il-GYTas-3RtxA"' api.accounts.freedom.tm/user
The above will return :
{
first_name : 'Annie',
last_name : 'Batumbakal',
email : 'dispachadora@gmail.com',
//along with other details associated with the account.
}
The same can be done in any other programming language, and this data can prove valuable to sessions, profile dashobards, etc.
This happens when you supplied the wrong redirect_uri parameter to /auth. Make sure your URL is listed
by the server admin.
Might be the cause of a typo or an inexistent service supplied to service parameter on /auth.