|
| 1 | +******************************************************************************* |
| 2 | +* Licensed by AT&T under 'Software Development Kit Tools Agreement.' |
| 3 | +* |
| 4 | +* 2013 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION: |
| 5 | +* http://developer.att.com/sdk_agreement/ |
| 6 | +* |
| 7 | +* Copyright 2013 AT&T Intellectual Property. All rights reserved. |
| 8 | +* http://developer.att.com |
| 9 | +* |
| 10 | +* For more information contact developer.support@att.com |
| 11 | +******************************************************************************* |
| 12 | + |
| 13 | + AT&T API Platform Sample Apps |
| 14 | + -------------------------------------- |
| 15 | + |
| 16 | + This file describes how to set up, configure and run the Ruby sample |
| 17 | + applications using the AT&T API Platform services. It covers all steps |
| 18 | + required to register the applications on DevConnect as well as running the |
| 19 | + sample applications locally. |
| 20 | + |
| 21 | + 1. Configuration |
| 22 | + 2. Installation |
| 23 | + 3. Parameters |
| 24 | + 4. Running the application |
| 25 | + |
| 26 | + |
| 27 | +1. Configuration |
| 28 | + |
| 29 | + Configuration consists of a few steps necessary to get an application |
| 30 | + registered on DevConnect with the proper services and endpoints, depending on |
| 31 | + the type of client-side application (autonomous/non-autonomous). |
| 32 | + |
| 33 | + To register an application, go to https://devconnect-api.att.com/ and login |
| 34 | + with your valid username and password. Next, choose "My Apps" from the bar at |
| 35 | + the top of the page and click the "Setup a New Application" button. |
| 36 | + |
| 37 | + Fill in the form, in particular all fields marked as "required". |
| 38 | + |
| 39 | + Be careful while filling in the "OAuth Redirect URL" field. It should contain |
| 40 | + the URL that the OAuth provider will redirect users to when he/she |
| 41 | + successfully authenticates and authorizes your application. The oauth |
| 42 | + redirect field must match the redirect specified in the app's config.yml |
| 43 | + |
| 44 | + NOTE: You MUST select the Sample Applications name in the list of services |
| 45 | + under field 'Services' in order to enable access to the cloud api. |
| 46 | + |
| 47 | + After your application is registered you will receive an API and Secret key. |
| 48 | + They are necessary for your registered applications to access the AT&T |
| 49 | + Platform APIs. See 'Adjusting parameters' below to learn how to use these |
| 50 | + keys in your applications. |
| 51 | + |
| 52 | + Initially your newly registered application is restricted to the "Sandbox" |
| 53 | + environment only. To move it to production, you may promote it by clicking |
| 54 | + the "Promote to production" button. Notice that you will get a different API |
| 55 | + key and secret, so these values in your application should be adjusted |
| 56 | + accordingly. |
| 57 | + |
| 58 | + Depending on the kind of authentication used, an application may be based on |
| 59 | + either the Autonomous Client or the Web-Server Client OAuth flow; see: |
| 60 | + https://devconnect-api.att.com/docs/oauth20/autonomous-client-application-oauth-flow |
| 61 | + https://devconnect-api.att.com/docs/oauth20/web-server-client-application-oauth-flow |
| 62 | + |
| 63 | + |
| 64 | +2. Installation |
| 65 | + |
| 66 | +** Requirements |
| 67 | + |
| 68 | + To run the examples you will need ruby 1.8+ and a few ruby gems that the |
| 69 | + applications are built upon: |
| 70 | + |
| 71 | + - sinatra: (http://www.sinatrarb.com/) used to construct a simple web |
| 72 | + application and manage URLs within. |
| 73 | + |
| 74 | + - sinatra-contrib: additional set of useful helpers, including ones used to |
| 75 | + read settings from external files. |
| 76 | + |
| 77 | + - rest-client: library for making restful calls |
| 78 | + |
| 79 | + - json: used for encoding and decoding requests/responses |
| 80 | + |
| 81 | + - att-codekit: library developed around the att cloud services (see below |
| 82 | + to install) |
| 83 | + - rake: compiling tool used to make att-codekit |
| 84 | + - yard: documentation tool used by att-codekit |
| 85 | + |
| 86 | + To install these gems open up a terminal window and invoke: |
| 87 | + |
| 88 | + gem install sinatra sinatra-contrib rest-client json rake yard |
| 89 | + |
| 90 | + On a *nix based system you may need to raise your access privliges, such as |
| 91 | + prefixing the command with sudo or logging in as root by running su. |
| 92 | + |
| 93 | +** Installing the att-codekit library |
| 94 | +Note: required for ruby 1.9+ and suggested for 1.8 |
| 95 | + |
| 96 | + The code kit library can be installed by using our hosted gem file. |
| 97 | + |
| 98 | + gem sources --add http://ldev.code-apt-att.com:8808 |
| 99 | + gem install att-codekit |
| 100 | + |
| 101 | + Note that the codekit is under heavy development and is using a semantic |
| 102 | + versioning scheme. Non-backwards compatible changes _will_ increase the |
| 103 | + major version number. |
| 104 | + |
| 105 | + |
| 106 | +** Setting up on a different port number |
| 107 | + |
| 108 | + In the case multiple applications need to be run at the same time, you need |
| 109 | + to use different port numbers. |
| 110 | + |
| 111 | + By default sinatra uses port number 4567; however only one running |
| 112 | + application may use this port. In the case that you want to run more than one |
| 113 | + sinatra-based application, you will need to update each applications' port |
| 114 | + number (located in config.yml). |
| 115 | + |
| 116 | + eg. application 1 - port: 4567, application 2 - port: 4568 |
| 117 | + |
| 118 | + The alternative is to set up your webserver to use a tool such as phusion |
| 119 | + passenger. Setting up a webserver, however, is beyond the scope of this |
| 120 | + article. |
| 121 | + |
| 122 | + |
| 123 | +3. Parameters |
| 124 | + |
| 125 | + Each application contains a config.yml file. It holds configurable parameters |
| 126 | + described in the easy to read format YAML. You are free to adjust these to |
| 127 | + your needs. If you introduce a change make sure to restart the application |
| 128 | + for it to take effect. |
| 129 | + |
| 130 | + The following are short descriptions of commonly used parameters: |
| 131 | + |
| 132 | + REQUIRED - |
| 133 | + 1) FQDN : The main server handling requests, ex: https://api.att.com |
| 134 | + |
| 135 | + 2) api_key : set the value as per your registered application 'API |
| 136 | + key' field value |
| 137 | + |
| 138 | + 3) secret_key : set the value as per your registered application |
| 139 | + 'Secret key' field value |
| 140 | + |
| 141 | + OPTIONAL - |
| 142 | + 4) port : The port number which the application will run standalone |
| 143 | + |
| 144 | + 5) tokens_file : The path where the oauth token will be saved. This option |
| 145 | + is only usable in client credential style authentication. |
| 146 | + Must have write permissions. |
| 147 | + |
| 148 | + Note: If your application is promoted from the Sandbox environment to |
| 149 | + Production environment and you decide to use production application settings, |
| 150 | + you must update api_key and secret_key as per production application details. |
| 151 | + |
| 152 | + |
| 153 | +4. Running the application |
| 154 | + |
| 155 | + To run the application, open up a terminal window in the application's |
| 156 | + directory and type: |
| 157 | + |
| 158 | + ruby (app name).rb |
| 159 | + |
| 160 | + Where (app name) is replaced with the current directories app name. |
| 161 | + |
| 162 | + Your application by default is accessible in a web browser at the url: |
| 163 | + http://localhost:4567/ |
| 164 | + |
| 165 | + You may interrupt the application at any time by pressing ctrl-C. |
| 166 | + |
| 167 | + |
0 commit comments