SlideShare una empresa de Scribd logo
1 de 30
Araport Workshop Tutorial 2: 
Authentication and the Profiles 
araport.org 
Service 
Stephen Mock 
Director, Advanced Computing Interfaces 
Texas Advanced Computing Center
araport.org 
this 
• http://www.slideshare.net/stevemock/arap 
ort-workshop-tutorial-2
araport.org 
Overview 
• Traditional Web Authentication 
• OAuth v2 
• Araport Client Registration 
• Javascript Developer Console 
• Building the “whoami” app
araport.org 
Goal 
• Build a client application to Araport’s web 
service platform, Agave 
• Have a working, authenticated web 
application running on your computer 
• Query the Agave “profiles” service for 
information about your account and 
display on the page and to the console
araport.org 
Araport Architecture 
CLI clients, 
Scripts, 3rd party 
applications 
Agave Enterprise Service Bus 
Agave Services 
systems apps 
jobs 
Physical 
resources 
profile 
meta 
files 
HPC | Files | DB 
ADAMA 
enroll 
manage 
a b c d e f 
AIP & 3rd party data 
providers 
• Single-sign on 
• Throttling 
• Unified logging 
• API versioning 
• Automatic 
HTTPS 
API Mediators 
• Simple proxy 
• Mediator 
• Aggregator 
• Filter 
REST-like 
REST* 
SOAP 
POX 
Cambrian CGI
Traditional Web Authentication 
• Browser sends username/password to 
server 
• Server verifies username/password and 
sends cookie back to browser 
• Browser sends cookie along with every 
request 
• Server decodes the cookie to determine 
authentication status 
araport.org
araport.org 
Traditional Cookie Auth 
CS 
S 
DB 
Login Form 
HTML 
CGI 
Store 
Cookie 
Server 
Browser 
HTTP 
Username 
Password Cookie 
All Further 
Requests 
Cookie
araport.org 
OAuth 2.0 
• Sounds scary, but you use it all the time 
• “Sign in/Register using your 
Twitter/Google/Facebook/Github/Microsoft 
account” 
• Trusted 3rd party for identity information, 
authorization, and authentication 
Skype 
Code.org
araport.org 
What is a Client 
• What is an OAuth Client? 
– Any software that consumes the Agave web 
services 
• Command line 
• Curl 
• Scripts 
• Web applications 
• Desktop Applications 
• Javascript 
• Araport.org
araport.org 
Simplified OAuth 2.0 Flow 
Araport.org, 
CLI clients, 
Scripts, 
3rd party applications 
Agave Web Services 
Clients 
Registration 
Service 
1) Register Client: 
• Send client “name” 
• Send 
username/password 
• Receive Client 
Credentials 
2) Authenticate: 
• “Login” 
• Send client credentials 
and username 
password 
• Receive access token 
3) Get Profile 
info: 
• Send client 
credentials 
• Send access 
token 
• Receive profile 
info 
Token Service Profiles Service
araport.org 
Araport Clients 
• We’re building clients to the Agave API 
• Authentication is to the Agave API not to 
the Araport.org website 
• Client Registration 
– All clients to the Agave API must register 
– For the development of your application 
– Araport.org is a client to the API as well!
araport.org 
Open Your App 
• First, check in tutorial 1 code (if you 
haven’t already) 
– git add . 
– git commit –a 
• Check out code for tutorial 2 
– git checkout tutorial/2 
• grunt 
• Opens browser to localhost:9000
araport.org 
Client Registration
Browser Javascript Developer 
araport.org 
Console 
• In Chrome 
– Command – Option – J (Mac) 
– Control – Shift – J (Linux / Windows) 
– Or View -> Developer -> Javascript Console 
– You should see: “Hello, workshop tutorial!“ 
• “console.log(object)” from Javascript prints 
information to the console 
– console.log(‘string’,object) if you want to output a 
string and an object like console.log(‘Success!’, 
successObject) 
• More info: https://developer.mozilla.org/en- 
US/docs/Web/API/Console.log
araport.org 
Developer Console 
• Agave documentation built into the 
browser! (Chrome, Safari, Firefox) 
• Type into console: 
– Agave.api.help(); 
• Notice all of the different endpoints 
– Agave.api.biscuit(); 
– Agave.api.profiles.help(); 
• Which do you think returns your profile?
araport.org 
Whoami App 
• Let’s build a “Hello world” type app! 
• Modify app/scripts/app.js and 
app/app.html to call Agave API to get your 
profile information and print it: 
1. To the Javascript console 
2. On the page
Agave.api Calls in Javascript 
araport.org 
• Agave.api.* 
Agave.api.endpoint( 
{ inputObject }, //input to the call, or null 
successCallbackFunction(response){ 
//runs if the Agave call is successful 
//still could make the call to Agave, 
//but return an error or other failure! 
}, 
failureCallbackFunction(err) { 
//runs if the Agave call fails to return 
} 
);
Agave.profiles.me Call in Javascript 
araport.org 
var successFunction = function(response) { 
//do success stuff! 
console.log(‘Success! ‘, response); 
}; 
var failFunction = function(err) { 
//do failure stuff! 
console.log(‘Failure! ‘, err); 
}; 
Agave.api.profiles.me( 
null, //no input needed here 
successFunction, 
failFunction 
);
araport.org 
STEP 1: 
• Delete code tutorial 1 code from app/scripts/app.js 
– Delete: 
• From: “//STEP 1: Beginning of STEP 1 code. Delete from here 
to "STEP 1: DELETE TO HERE " below//” 
• To: “//STEP 1: DELETE TO HERE //” 
• Uncomment STEP 1: code in app/scripts/app.js 
– Delete the 2 lines that say: 
• “/**** To uncomment for STEP 1 delete this entire line ********” 
• “*** To uncomment for STEP 1 delete this entire line ********/” 
• Save the file app/scripts/app.js to reload the app 
• See response object printed to console 
• Browse the response object in console
araport.org 
Console Output
araport.org 
Response object 
• The object returned to the success callbacks from the 
Agave.api calls 
• You can call it anything you want, resp (for short) or 
biscuits if you wanted 
• Important (to this workshop) properties: 
– data: raw string data 
– obj: { JSON representation of data } //more in next slide 
– status: the http code of the call 
• http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 
• 2xx – Success codes! You want these! 
• 3xx – Redirect codes, typically ok. 
• 4xx – Client errors. Your code probably sent the wrong 
request/info! 
• 5xx – Server errors. The server had an error!
araport.org 
results.obj 
• If returned data is JSON, it gets stuffed into results.obj 
– message: a human readable message 
– result: { the information you requested } 
• From Agave.api.profiles.me() 
– create_time: "20140812212443Z” 
– email: mock@tacc.utexas.edu 
– first_name: ”Stephen” 
– full_name: ”Stehen Mock” 
– last_name: ”Mock” 
– mobile_phone: "” 
– phone: "” 
– status: "Active” 
– username: "mock" 
– status: “success or failure” 
• Check this for ‘success’
araport.org 
In Javascript: 
Check status, Print username 
var successFunction = function(response) { 
//do success stuff! 
console.log(response); //everything! 
if(response.obj.status !== 'success') { 
console.log('There was a problem: ' + 
response.obj.message); 
} else { 
console.log('Success! Welcome, ', 
response.obj.result.username); 
} 
};
araport.org 
STEP 2 
• Delete STEP 1 code from 
app/scripts/app.js 
• Uncomment STEP 2 code from 
app/scripts/app.js 
• Note: 
– Checking the response.obj.status for 
‘success’ 
– Printing the username to the console via 
response.obj.result.username
araport.org 
Console Output
araport.org 
Putting It On The Page 
• var appContext = $('[data-app-name=" 
workshop-tutorial"]'); 
– Use this to find/modify any elements in the page so 
that you don’t clobber other apps when it’s 
published to Araport.org 
– For example: 
• $('.profile-name', appContext).text(profile.username); 
• var vcard = $('.vcard', appContext);
araport.org 
Step 3: 
Let’s Put It on the Page 
• Delete STEP 1 and 2 code in BOTH 
– app/app.html 
– app/scripts/app.js 
• Uncomment STEP 3 code in BOTH 
– app/app.html 
– app/scripts/app.js 
• Save both files to reload 
• Note: 
– More profile information pushed to console 
– Vcard (profile info) displayed on the page
araport.org 
Conclusion 
• Learned a bit about OAuth v2 
• Got a glimpse into the Agave API 
• Built an app in several steps that queries 
Agave for profile information and displays 
that information in the console and on a 
page
Chris Nelson 
Project 
Manager 
araport.org 
Chris Town, PI 
Lisa McDonald 
Education and 
Outreach 
Coordinator 
Jason Miller, Co-PI 
JCVI Technical Lead 
Vivek Krishnakumar 
Bioinf. Engineer 
Erik Ferlanti 
Software Engineer 
Svetlana Karamycheva 
Bioinf Engineer 
Gos Micklem, co-PI Sergio Contrino 
Eva Huala 
Project lead, TAIR 
Software Engineer 
Bob Muller 
Technical lead, TAIR 
Matt Vaughn 
co-PI 
Steve Mock 
Portal Engineer 
Rion Dooley, 
API Engineer 
Matt Hanlon, 
Portal Engineer 
Maria Kim 
Bioinf Engineer 
Ben Rosen 
Bioinf 
Analyst 
Joe Stubbs, 
API 
Engineer 
Walter Moreira, 
API Engineer
araport.org 
Questions? 
mock@tacc.utexas.edu

Más contenido relacionado

La actualidad más candente

Ruby conf 2011, Create your own rails framework
Ruby conf 2011, Create your own rails frameworkRuby conf 2011, Create your own rails framework
Ruby conf 2011, Create your own rails framework
Pankaj Bhageria
 
Laravel Restful API and AngularJS
Laravel Restful API and AngularJSLaravel Restful API and AngularJS
Laravel Restful API and AngularJS
Blake Newman
 

La actualidad más candente (20)

Laravel 5
Laravel 5Laravel 5
Laravel 5
 
Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)
 
Ruby On Grape
Ruby On GrapeRuby On Grape
Ruby On Grape
 
Workshop Laravel 5.2
Workshop Laravel 5.2Workshop Laravel 5.2
Workshop Laravel 5.2
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
 
A introduction to Laravel framework
A introduction to Laravel frameworkA introduction to Laravel framework
A introduction to Laravel framework
 
Introduction to plugin development
Introduction to plugin developmentIntroduction to plugin development
Introduction to plugin development
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 
Introduction to laravel framework
Introduction to laravel frameworkIntroduction to laravel framework
Introduction to laravel framework
 
Don't worry be API with Slim framework and Joomla
Don't worry be API with Slim framework and JoomlaDon't worry be API with Slim framework and Joomla
Don't worry be API with Slim framework and Joomla
 
Ruby conf 2011, Create your own rails framework
Ruby conf 2011, Create your own rails frameworkRuby conf 2011, Create your own rails framework
Ruby conf 2011, Create your own rails framework
 
Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1
 
Laravel Restful API and AngularJS
Laravel Restful API and AngularJSLaravel Restful API and AngularJS
Laravel Restful API and AngularJS
 
Knowing Laravel 5 : The most popular PHP framework
Knowing Laravel 5 : The most popular PHP frameworkKnowing Laravel 5 : The most popular PHP framework
Knowing Laravel 5 : The most popular PHP framework
 
Rails antipattern-public
Rails antipattern-publicRails antipattern-public
Rails antipattern-public
 
Rails antipatterns
Rails antipatternsRails antipatterns
Rails antipatterns
 
Laravel Introduction
Laravel IntroductionLaravel Introduction
Laravel Introduction
 
Laravel for Web Artisans
Laravel for Web ArtisansLaravel for Web Artisans
Laravel for Web Artisans
 

Similar a Araport Workshop Tutorial 2: Authentication and the Agave Profiles Service

MesosCon - Be a microservices hero
MesosCon - Be a microservices heroMesosCon - Be a microservices hero
MesosCon - Be a microservices hero
Dragos Dascalita Haut
 

Similar a Araport Workshop Tutorial 2: Authentication and the Agave Profiles Service (20)

An introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBMAn introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBM
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework Basic
 
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
 
API Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIsAPI Workshop: Deep dive into REST APIs
API Workshop: Deep dive into REST APIs
 
Developing Apps with Azure AD
Developing Apps with Azure ADDeveloping Apps with Azure AD
Developing Apps with Azure AD
 
Exposing Salesforce REST Services Using Swagger
Exposing Salesforce REST Services Using SwaggerExposing Salesforce REST Services Using Swagger
Exposing Salesforce REST Services Using Swagger
 
Learn Electron for Web Developers
Learn Electron for Web DevelopersLearn Electron for Web Developers
Learn Electron for Web Developers
 
Building Better Web APIs with Rails
Building Better Web APIs with RailsBuilding Better Web APIs with Rails
Building Better Web APIs with Rails
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 
How to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxHow to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptx
 
Checkmarx meetup API Security - API Security in depth - Inon Shkedy
Checkmarx meetup API Security - API Security in depth - Inon ShkedyCheckmarx meetup API Security - API Security in depth - Inon Shkedy
Checkmarx meetup API Security - API Security in depth - Inon Shkedy
 
Workshop: We love APIs
Workshop: We love APIsWorkshop: We love APIs
Workshop: We love APIs
 
API Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentestersAPI Security - OWASP top 10 for APIs + tips for pentesters
API Security - OWASP top 10 for APIs + tips for pentesters
 
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
 
Apex Code Analysis Using the Tooling API and Canvas
Apex Code Analysis Using the Tooling API and CanvasApex Code Analysis Using the Tooling API and Canvas
Apex Code Analysis Using the Tooling API and Canvas
 
OCI Oracle Functions Deployment
OCI Oracle Functions Deployment OCI Oracle Functions Deployment
OCI Oracle Functions Deployment
 
03 integrate webapisignalr
03 integrate webapisignalr03 integrate webapisignalr
03 integrate webapisignalr
 
MesosCon - Be a microservices hero
MesosCon - Be a microservices heroMesosCon - Be a microservices hero
MesosCon - Be a microservices hero
 
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
Workshop KrakYourNet2016 - Web applications hacking Ruby on Rails example
 
Developing Apps: Exposing Your Data Through Araport
Developing Apps: Exposing Your Data Through AraportDeveloping Apps: Exposing Your Data Through Araport
Developing Apps: Exposing Your Data Through Araport
 

Último

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Último (20)

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

Araport Workshop Tutorial 2: Authentication and the Agave Profiles Service

  • 1. Araport Workshop Tutorial 2: Authentication and the Profiles araport.org Service Stephen Mock Director, Advanced Computing Interfaces Texas Advanced Computing Center
  • 2. araport.org this • http://www.slideshare.net/stevemock/arap ort-workshop-tutorial-2
  • 3. araport.org Overview • Traditional Web Authentication • OAuth v2 • Araport Client Registration • Javascript Developer Console • Building the “whoami” app
  • 4. araport.org Goal • Build a client application to Araport’s web service platform, Agave • Have a working, authenticated web application running on your computer • Query the Agave “profiles” service for information about your account and display on the page and to the console
  • 5. araport.org Araport Architecture CLI clients, Scripts, 3rd party applications Agave Enterprise Service Bus Agave Services systems apps jobs Physical resources profile meta files HPC | Files | DB ADAMA enroll manage a b c d e f AIP & 3rd party data providers • Single-sign on • Throttling • Unified logging • API versioning • Automatic HTTPS API Mediators • Simple proxy • Mediator • Aggregator • Filter REST-like REST* SOAP POX Cambrian CGI
  • 6. Traditional Web Authentication • Browser sends username/password to server • Server verifies username/password and sends cookie back to browser • Browser sends cookie along with every request • Server decodes the cookie to determine authentication status araport.org
  • 7. araport.org Traditional Cookie Auth CS S DB Login Form HTML CGI Store Cookie Server Browser HTTP Username Password Cookie All Further Requests Cookie
  • 8. araport.org OAuth 2.0 • Sounds scary, but you use it all the time • “Sign in/Register using your Twitter/Google/Facebook/Github/Microsoft account” • Trusted 3rd party for identity information, authorization, and authentication Skype Code.org
  • 9. araport.org What is a Client • What is an OAuth Client? – Any software that consumes the Agave web services • Command line • Curl • Scripts • Web applications • Desktop Applications • Javascript • Araport.org
  • 10. araport.org Simplified OAuth 2.0 Flow Araport.org, CLI clients, Scripts, 3rd party applications Agave Web Services Clients Registration Service 1) Register Client: • Send client “name” • Send username/password • Receive Client Credentials 2) Authenticate: • “Login” • Send client credentials and username password • Receive access token 3) Get Profile info: • Send client credentials • Send access token • Receive profile info Token Service Profiles Service
  • 11. araport.org Araport Clients • We’re building clients to the Agave API • Authentication is to the Agave API not to the Araport.org website • Client Registration – All clients to the Agave API must register – For the development of your application – Araport.org is a client to the API as well!
  • 12. araport.org Open Your App • First, check in tutorial 1 code (if you haven’t already) – git add . – git commit –a • Check out code for tutorial 2 – git checkout tutorial/2 • grunt • Opens browser to localhost:9000
  • 14. Browser Javascript Developer araport.org Console • In Chrome – Command – Option – J (Mac) – Control – Shift – J (Linux / Windows) – Or View -> Developer -> Javascript Console – You should see: “Hello, workshop tutorial!“ • “console.log(object)” from Javascript prints information to the console – console.log(‘string’,object) if you want to output a string and an object like console.log(‘Success!’, successObject) • More info: https://developer.mozilla.org/en- US/docs/Web/API/Console.log
  • 15. araport.org Developer Console • Agave documentation built into the browser! (Chrome, Safari, Firefox) • Type into console: – Agave.api.help(); • Notice all of the different endpoints – Agave.api.biscuit(); – Agave.api.profiles.help(); • Which do you think returns your profile?
  • 16. araport.org Whoami App • Let’s build a “Hello world” type app! • Modify app/scripts/app.js and app/app.html to call Agave API to get your profile information and print it: 1. To the Javascript console 2. On the page
  • 17. Agave.api Calls in Javascript araport.org • Agave.api.* Agave.api.endpoint( { inputObject }, //input to the call, or null successCallbackFunction(response){ //runs if the Agave call is successful //still could make the call to Agave, //but return an error or other failure! }, failureCallbackFunction(err) { //runs if the Agave call fails to return } );
  • 18. Agave.profiles.me Call in Javascript araport.org var successFunction = function(response) { //do success stuff! console.log(‘Success! ‘, response); }; var failFunction = function(err) { //do failure stuff! console.log(‘Failure! ‘, err); }; Agave.api.profiles.me( null, //no input needed here successFunction, failFunction );
  • 19. araport.org STEP 1: • Delete code tutorial 1 code from app/scripts/app.js – Delete: • From: “//STEP 1: Beginning of STEP 1 code. Delete from here to "STEP 1: DELETE TO HERE " below//” • To: “//STEP 1: DELETE TO HERE //” • Uncomment STEP 1: code in app/scripts/app.js – Delete the 2 lines that say: • “/**** To uncomment for STEP 1 delete this entire line ********” • “*** To uncomment for STEP 1 delete this entire line ********/” • Save the file app/scripts/app.js to reload the app • See response object printed to console • Browse the response object in console
  • 21. araport.org Response object • The object returned to the success callbacks from the Agave.api calls • You can call it anything you want, resp (for short) or biscuits if you wanted • Important (to this workshop) properties: – data: raw string data – obj: { JSON representation of data } //more in next slide – status: the http code of the call • http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html • 2xx – Success codes! You want these! • 3xx – Redirect codes, typically ok. • 4xx – Client errors. Your code probably sent the wrong request/info! • 5xx – Server errors. The server had an error!
  • 22. araport.org results.obj • If returned data is JSON, it gets stuffed into results.obj – message: a human readable message – result: { the information you requested } • From Agave.api.profiles.me() – create_time: "20140812212443Z” – email: mock@tacc.utexas.edu – first_name: ”Stephen” – full_name: ”Stehen Mock” – last_name: ”Mock” – mobile_phone: "” – phone: "” – status: "Active” – username: "mock" – status: “success or failure” • Check this for ‘success’
  • 23. araport.org In Javascript: Check status, Print username var successFunction = function(response) { //do success stuff! console.log(response); //everything! if(response.obj.status !== 'success') { console.log('There was a problem: ' + response.obj.message); } else { console.log('Success! Welcome, ', response.obj.result.username); } };
  • 24. araport.org STEP 2 • Delete STEP 1 code from app/scripts/app.js • Uncomment STEP 2 code from app/scripts/app.js • Note: – Checking the response.obj.status for ‘success’ – Printing the username to the console via response.obj.result.username
  • 26. araport.org Putting It On The Page • var appContext = $('[data-app-name=" workshop-tutorial"]'); – Use this to find/modify any elements in the page so that you don’t clobber other apps when it’s published to Araport.org – For example: • $('.profile-name', appContext).text(profile.username); • var vcard = $('.vcard', appContext);
  • 27. araport.org Step 3: Let’s Put It on the Page • Delete STEP 1 and 2 code in BOTH – app/app.html – app/scripts/app.js • Uncomment STEP 3 code in BOTH – app/app.html – app/scripts/app.js • Save both files to reload • Note: – More profile information pushed to console – Vcard (profile info) displayed on the page
  • 28. araport.org Conclusion • Learned a bit about OAuth v2 • Got a glimpse into the Agave API • Built an app in several steps that queries Agave for profile information and displays that information in the console and on a page
  • 29. Chris Nelson Project Manager araport.org Chris Town, PI Lisa McDonald Education and Outreach Coordinator Jason Miller, Co-PI JCVI Technical Lead Vivek Krishnakumar Bioinf. Engineer Erik Ferlanti Software Engineer Svetlana Karamycheva Bioinf Engineer Gos Micklem, co-PI Sergio Contrino Eva Huala Project lead, TAIR Software Engineer Bob Muller Technical lead, TAIR Matt Vaughn co-PI Steve Mock Portal Engineer Rion Dooley, API Engineer Matt Hanlon, Portal Engineer Maria Kim Bioinf Engineer Ben Rosen Bioinf Analyst Joe Stubbs, API Engineer Walter Moreira, API Engineer

Notas del editor

  1. 3 arguments to most of the API calls: Input object Success callback function Failure callback function
  2. first thing you'll do is blow away the API docs anyway from your generated app.
  3. Probably not necessary to check the error codes because the Agave api takes care of that. But it’s not a bad idea to check the http codes as well eventually for completeness. We’re glossing over that a little bit here to make the code more readable.
  4. An expanded “successFunction” showing: -checking the response.obj.status for success -printing out the username via response.obj.result.username
  5. This is JQuery foo.
  6. 25 MINUTES