Skip to content

Instantly share code, notes, and snippets.

@richessler
Created May 28, 2016 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richessler/49fd39c85bb28a8d7414759f541aa453 to your computer and use it in GitHub Desktop.
Save richessler/49fd39c85bb28a8d7414759f541aa453 to your computer and use it in GitHub Desktop.
# Create an application
# This is all done in rails console while in the project folder
app = Doorkeeper::Application.create :name => 'test', :redirect_uri => 'https://richard-district-api.herokuapp.com/'
# => #<Doorkeeper::Application id: 5, name: "test", uid: "19cba7b2992094e27d3c24015986bb86c1dafeb3fc1a1529c1...", secret: "999e925987a7e7e48b6511752558e103fb3b96349d23cc7b0c...", redirect_uri: "https://richard-district-api.herokuapp.com/", scopes: "", created_at: "2016-05-28 01:18:18", updated_at: "2016-05-28 01:18:18">
# NOTE: The redirect is an example, but really just needs to be a valid url for this to work, if doing on heroku, it has to be HTTPS, local can be http.
# Get Client ID and Client Secret
app.uid
# => "19cba7b2992094e27d3c24015986bb86c1dafeb3fc1a1529c1fe6703608d4a9b"
app.secret
# => "999e925987a7e7e48b6511752558e103fb3b96349d23cc7b0ce90f0e2489a837"
# If you do not have postman, download it and do the following:
# with OAuth2 selected from the dropdown make a POST to (this is an example):
# localhost:3000/oauth/token?client_id=<app.uid>&client_secret=<app.secret>&grant_type=client_credentials
# Sample response from POST
{
"access_token": "a9be1a65a6344d03c3e0ebcfe6f8438c54df4beabdcaf644758efa6545adf458",
"token_type": "bearer",
"expires_in": 7200,
"created_at": 1464398873
}
# To use the validation in the `Authorization` field in swagger, or with front end you'll enter: `bearer a9be1a65a6344d03c3e0ebcfe6f8438c54df4beabdcaf644758efa6545adf458`
# Following these steps should get you to the authorization you're looking for :D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment