Last active
March 11, 2019 15:06
-
-
Save orendon/e6ce1f492e2f504c2e8a to your computer and use it in GitHub Desktop.
Doorkeeper Oauth2 - Authorization Flows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/doorkeeper-gem/doorkeeper/wiki/Client-Credentials-flow | |
callback = "urn:ietf:wg:oauth:2.0:oob" | |
app_id = "28d7adbcf95a70fdcb6101a517645762b84a16ae5077b5e0b7a678f2f188b0d2" | |
secret = "0fc0c9ae38548404b001a3fdb3e9f4e90c22b78ba74df2104d7a37c1cb251687" | |
client = OAuth2::Client.new(app_id, secret, site: "http://localhost:3000/") | |
access = client.client_credentials.get_token | |
access.post("/api/v1/some/endpoint", params: { username: 'abc', password: 'xyz' }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Resource-Owner-Password-Credentials-flow | |
Doorkeeper.configure do | |
resource_owner_from_credentials do |routes| | |
User.authenticate!(params[:username], params[:password]) | |
end | |
end | |
# ---- | |
callback = "urn:ietf:wg:oauth:2.0:oob" | |
app_id = "28d7adbcf95a70fdcb6101a517645762b84a16ae5077b5e0b7a678f2f188b0d2" | |
secret = "0fc0c9ae38548404b001a3fdb3e9f4e90c22b78ba74df2104d7a37c1cb251687" | |
client = OAuth2::Client.new(app_id, secret, site: "http://localhost:3000/") | |
access = client.password.get_token('[email protected]', 'sekretpwd') | |
access.post("/api/v1/some/endpoint", params: { foo: 'abc', bar: 'xyz' }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment