Skip to content

Access is denied with Google Authentication using NextAuth.js #7212

Closed Answered by shirotamaki
shirotamaki asked this question in Help
Discussion options

You must be logged in to vote

@Crazypersonalph
Thanks for checking issue.
I can check that the Rails server is returning a 302.

  ↳ app/controllers/api/v1/users_controller.rb:13:in `create'
Redirected to http://localhost:4000
Completed 302 Found in 10ms (ActiveRecord: 1.8ms | Allocations: 3715)

I changed it to return only status code 200 OK, without redirect.

# backend/app/controllers/api/v1/users_controller.rb

     def create
        next_url = Rails.application.credentials.next_url
        user = User.find_or_create_by(provider: params[:provider], uid: params[:uid], name: params[:name], email: params[:email])
        if user
          head :ok
        else
          render json: { error: 'ログインに失敗しました' }, status: :…

Replies: 9 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by shirotamaki
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@hafsahussein
Comment options

@gauravdubey19
Comment options

@Thetwin21
Comment options

@fromSian
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
question Ask how to do something or how something works
7 participants
Converted from issue

This discussion was converted from issue #7205 on April 11, 2023 07:39.