Giter VIP home page Giter VIP logo

rally-oauth-examples's Introduction

Oauth Sample Apps

Each sample app has a README with instructions on running it and a Procfile for use with Foreman.

  1. Python - uses the sanction OAuth library and web.py.
  2. Ruby - uses Sinatra and RestClient, does not use an OAuth library.
  3. Clojure - Uses Compojure, http-kit and hiccup. Does not use an OAuth library.

Client Ids

To create a new Oauth integration, you will need to create a client id for your new application. You can create/modify clients at https://rally1.rallydev.com/login/accounts/index.html#/clients The page will ask you to enter a name and redirect_uri for your client. After saving it will give you a client_id and client_secret to use in your app. Zuul's oauth URLs are:

  • Authentication https://rally1.rallydev.com/login/oauth2/auth
  • Token https://rally1.rallydev.com/login/oauth2/token

API Key

API keys are strings that you can use in place of a zuul session token or username/password combination. You can generate and name as many keys as needed at https://rally1.rallydev.com/login/accounts/index.html#/keys To use one, you can make calls to alm with a cookie or header called zsessionid set to the secret_key value of your API key. You can delete or regenerate an existing API Key to revoke access to keys you have previously issued.

Revoking Grants

After you agree to let an oauth client access your data, you can remove the grant by visiting https://rally1.rallydev.com/login/accounts/index.html#/apps and clicking remove on the application you do not want to have access any longer.

Workflow

Go to https://rally1.rallydev.com/login/accounts/index.html#/clients and create a new Client for your application. Save the Client ID and Client Secret.

To gain an access token for a user from your app first

redirect to https://rally1.rallydev.com/login/oauth2/auth

Encode the following parameters onto the URL

  • state a key to use to validate the auth token, typically a UUID.
  • response_type set to 'code'.
  • redirect_uri this must match the URL you specified when creating your client id and secret.
  • client_id is the client_id that was created in Rally.
  • scope set to 'alm'.

For example: https://rally1.rallydev.com/login/oauth2/auth?state=e347b102-6029-49b0-81d7-5089d846812e&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A4567%2Foauth-redirect&client_id=817b4273628c415cddfd657ab7224582&scope=alm

In the handler for the URL you redirect to you need to get the code from the parameters and POST to the token endpoint.

You will recieve a JSON body with 'state' and 'code'.

  • state must match the 'state' you specified earlier.
  • token is the auth token that you can exchange for an access token.

To exchange the auth token for an access token:

POST to https://rally1.rallydev.com/login/oauth2/token

The BODY must contain the following parameters in URL/form encoded format.

  • code the 'code' you recieved.
  • redirect_uri must match the redirect_uri you specified earlier.
  • grant_type set to 'authorization_code'.
  • client_id set to your client id.
  • client_secret set to your client secret.

Ensure you set the Content-Type header to "application/x-www-form-urlencoded".

The response will either contain an error body in JSON such as

{"client_id":null, "client_secret":null, "error_description":"Invalid value for grant_type params - must be authorization_code", "error":"invalid_grant"}

or on success a JSON body of

{"id_token":"???","refresh_token":"8b829ee0a4cb45f6884f580433c98","expires_in":86400,"token_type":"Bearer","access_token":"Ovp8AQ4pRMADXUmzR44V5IFb8ViYUdxhYJkd123aQs"}

You can then use the access_token to make requests using the Rally Web Services API. On each request set the zsessionid header to the access token.

rally-oauth-examples's People

Contributors

grammati avatar homeyer avatar dgriff1 avatar eshiflet avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.