Skip to content

Commit

Permalink
Update README with redirect_uri example
Browse files Browse the repository at this point in the history
  • Loading branch information
scrogson committed Apr 6, 2015
1 parent a643209 commit c19d1a6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ alias OAuth2.Strategy.AuthCode
strategy = AuthCode.new([
client_id: "client_id",
client_secret: "abc123",
site: "https://auth.example.com"
site: "https://auth.example.com",
redirect_uri: "https://example.com/auth/callback"
])

# Generate the authorization URL and redirect the user to the provider.
AuthCode.authorize_url(strategy, %{redirect_uri: "https://example.com/auth/callback"})
AuthCode.authorize_url(strategy, %{redirect_uri: strategy.redirect_uri})
# => "https://auth.example.com/oauth/authorize?client_id=client_id&redirect_uri=https%3A%2F%2Fexample.com%2Fauth%2Fcallback&response_type=code"

# Use the authorization code returned from the provider to obtain an access token.
token = AuthCode.get_token!(strategy, "someauthcode", %{redirect_uri: "https://example.com/auth/callback"})
token = AuthCode.get_token!(strategy, "someauthcode", %{redirect_uri: strategy.redirect_uri})

# Use the access token to make a request for resources
resource = OAuth2.AccessToken.get!(token, "/api/resource")
Expand All @@ -42,7 +43,7 @@ resource = OAuth2.AccessToken.get!(token, "/api/resource")

The MIT License (MIT)

Copyright (c) 2014 Sonny Scroggin
Copyright (c) 2015 Sonny Scroggin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down

0 comments on commit c19d1a6

Please sign in to comment.