# Requires Jomres 9.9.6
# AngularJS authentication example using Implicit Grant Type
This is an example of how to get access to the Jomres REST API using the Implicit Grant Type.
Most Jomres example code uses the Client Credentials grant type, where both the client ID and Secret are passed by the client that's calling the Jomres API.
To get around that, you need the Implicit grant type, which works slightly differently to Client Credentials.
In Client Credentials flow you send both the ID and the secret and an access token is returned. Once you have that access token, you can call the REST API.
In Implicit flow you call the Jomres server using a special url which you can find on your Client page when you create an API key pair.
## Using the example code
### Install the API Core to your Jomres installation
1. First things first, if you haven't already install the API Core plugin into your Jomres installation via the Jomres Plugin Manager. You may need to visit Site Configuration : Misc tab and set the "Show API client configuration options in Jomres main menu?" option to Yes.
Once you have done that, you will be able to create REST API clients by visiting your property manager pages > Account Details > App Key Management.
Don't make any other changes to that page just yet, but keep it open in your browser as you'll refer back to it in a minute.
3. Next download the angularjs_authentication_example zip file from Jomres.net.
Unzip it to your desktop's local server. I.E. if you're using WAMP then that would typically be c:wamp64wwwangularjs_authentication_example.
You will need to modify one, perhaps two files.
Open up oauth_callback.html. The line that says
might need to be changed if you have the files in a different directory to c:wamp64wwwangularjs_authentication_example
Copy this url ( E.G. http://localhost/angularjs_authentication_example/oauth_callback.html ) to your clipboard and back in your browser change the Redirect URI in the REST API Client Details page to this uri.
Save the file.
4. Open up app.js in the "js" directory. In the line that says
Change the URL to the Authorisation URL that's displayed in your browser. It looks something like this
Save the file.
6. Save the REST API client in your Jomres browser.
7. You're now ready to test the installation. In a new tab visit http://localhost/angularjs_authentication_example/ You should see a button "login to Jomres". Click on it and you will be taken to the authorisation page on your Jomres installation. If you haven't already logged in with your property manager's username and password you will need to do that.
Next you will see a message saying "Do You Authorize xxxxxxxx" where xxxxxxxx represents your client id that you just created. Click Yes.
You should now see a message like
`Secure Web Page
Access Token: 3d9ec21300333e71bcdd58b608a0feee0b5e8898`
Developed and maintained by Vince Wooll, Jomres was initially conceived in early 2005 as a Mambo based solution to a client’s hotel management needs. While it wasn't originally expected to be an online booking system it quickly morphed into one as users requested more and more features.
As the number of feature requests grew Vince knew that he would need to dedicate more time to the project and in July 2005 Jomres was formally released as a commercial project. Since then, Jomres has become one of Mambo’s, and now Joomla’s, longest running projects. It has survived various versions of Mambo, then Joomla 1.0, 1.5, 1.6, 1.7, 2.5 and 3.
Aladar joined the project in 2010 after using Jomres for his own projects. He was active on the forum, helping other members of the community and eventually Vince invited him to join the team. Between 2010 and 2018 he was an integral part of the project and made many significant contributions.
Whilst not formally part of the Jomres project, Rodrigo Rocco and Vince have become firm friends. Rod is a freelancer who specialises in doing custom work for Jomres users and developing custom plugins for the system that take advantage of it's modular design. He has built many useful extensions including his fabulous Valentina Template Override Package.
Jomres and the Jomres Logo is trademarked and can't be used without written consent from the owner.
www.jomres.net is not affiliated with or endorsed by the Joomla! Project, Open Source Matters or the WordPress project. The Joomla! & WordPress names and logos are used under a limited license granted by Open Source Matters and the WordPress Projects.
© Copyright 2005 - 2020 Woollyinwales IT.