Closed chasers closed 5 years ago
You should update your routes to this:
pipeline :protected do
# Require user authentication
end
scope "/" do
pipe_through :api
oauth_api_routes()
end
scope "/" do
pipe_through [:browser, :protected]
oauth_routes()
end
Also the changelog has the upgrade steps required: https://github.com/danschultzer/phoenix_oauth2_provider/blob/v0.5.0/CHANGELOG.md#v050-2019-05-08
Hmmm now:
rotocol.UndefinedError at GET /oauth/authorized_applications
protocol Ecto.Queryable not implemented for Logflare.OauthAccessTokens.OauthAccessToken, the given module does not exist. This protocol is implemented for: BitString, Tuple, Ecto.Query, Atom, Ecto.SubQuery
Run mix ex_oauth2_provider.gen.schemas
. The schema modules are now required to be generated, but it makes it much more explicit and easy to work with.
Okay now this:
UndefinedFunctionError at GET /oauth/authorized_applications
function nil.all/1 is undefined
Remove the previous PhoenixOauth2Provider config and change it to this:
config :logflare, ExOauth2Provider,
repo: Logflare.Repo,
resource_owner: Logflare.User,
grant_flows: ~w(authorization_code),
use_refresh_token: true,
default_scopes: ~w(public),
optional_scopes: ~w(read write),
revoke_refresh_token_on_use: true
config :logflare, PhoenixOauth2Provider,
current_resource_owner: :user,
web_module: LogflareWeb
Sweet, and now it seems I have to do something with my views?
Thanks a lot, this is much appreciated.
I tried mix phoenix_oauth2_provider.gen.templates
but it didn't seem to regen anything.
Oh wait, it's prompting me... hold on.
It's probably because the view files are already there, but the module names are different. You can just delete the lib/logflare_web/views/phoenix_oauth2_provider
folder and then run the mix task again. The templates folders lib/logflare_web/templates/{application, authorization, authorized_application}
should be moved to lib/logflare_web/templates/phoenix_oauth_provider/{application, authorization, authorized_application}
Okay I think I can manage from here! Got one of my view working.
Great, and thanks for the feedback! I've used it to update the changelog with better instructions.
I think the best way is just to regenerate all the templates/views from scratch, and then update the templates after with your previous styling. There's a few changes to what assigns there is access to (e.g. @application
is now @changeset.data
in some of them).
In the end, these changes will make PhoenixOauth2Provider much easier to work with in the future, and the new structure should make your project cleaner to navigate 😄
Glad it helped.
btw I didn't have an updated_at
column in the oauth_access_grants
. Seems the originally generated migration omitted it for some reason and now it is expected.
This helped:
def change do
alter table(:oauth_access_grants) do
timestamps(default: "2019-05-08 00:00:01", inserted_at: false)
end
end
That works. You can also just set the :updated_at
option in the timestamp/1
schema macro in the Logflare.OauthAccessGrants.OauthAccessGrant
module:
schema "oauth_access_grants" do
access_grant_fields()
timestamps(updated_at: false)
end
Ah nice ... that worked too. Would rather do that I think.
I should be integrating Pow soon actually. Need to build billing first but I think after that.
Thanks for updating this! Was actually thinking about it the other day.
However now I'm getting: