Malformed auth_url

Hey need some assistance here, I've been stuck here for days. I've deployed a rails application on webapp.io and everything runs smoothly but when I try to login by going to KindeSdk.auth_url the ulr that comes to the browser is https://oauth2/auth?client_id=<......> Can you help?
No description
6 Replies
Francisco Ribeiro
Francisco RibeiroOP•13mo ago
I made sure by accessing the environment to make sure the KINDE_DOMAIN environment variable exists and it does:
No description
onderay
onderay•13mo ago
Sorry in the delay @Francisco Ribeiro and for you spending your time to resolve this. I am going to speak with a team member more experinced than me with RoR and get back to you.
Francisco Ribeiro
Francisco RibeiroOP•13mo ago
Thanks! I'll be waiting then
viv (kinde)
viv (kinde)•13mo ago
Hey @Francisco Ribeiro - thanks for raising this, I'm taking a look 😃 . Just checking if all the other .env variables are coming through correctly and it's just KINDE_DOMAIN that's not? Also if you've tried something like https://stackoverflow.com/a/56035251/19597920 already? Thanks!
Stack Overflow
Rails doesn't see environment variable
I am trying to move a Rails application into production but I am having a problem with Rails not seeing my environment variable. I have the password for my database setup in my .bashrc file like
Francisco Ribeiro
Francisco RibeiroOP•13mo ago
Hey @viv (kinde) , sorry I only had time now to answer. It seems the problem is not in the environment loading since in the request above, the clientId is sent and it's coming from the same env. Only domain is giving problems. For more context, this is the controller and the Kindesdk configuration.
No description
No description
viv (kinde)
viv (kinde)•13mo ago
Hey @Francisco Ribeiro - no worries at all! Hmm, wacky - would you be able to take a look at this and see if this works for you?
class AuthController < ApplicationController
def auth
auth = KindeSdk.auth_url
session[:code_verifier] = auth[:code_verifier] if auth[:code_verifier].present?
redirect_to auth[:url], allow_other_host: true
end

def callback
session[:kinde_auth] =
KindeSdk
.fetch_tokens(params["code"], code_verifier: KindeSdk.config.pkce_enabled ? session[:code_verifier] : nil)
.slice(:access_token, :refresh_token, :expires_at)

user_profile = KindeSdk.client(session[:kinde_auth]).oauth.get_user
session[:kinde_user] = user_profile.to_hash

redirect_to root_path
end

def client_credentials_auth
result = KindeSdk.client_credentials_access(
client_id: ENV["KINDE_MANAGEMENT_CLIENT_ID"],
client_secret: ENV["KINDE_MANAGEMENT_CLIENT_SECRET"]
)
raise result if result["error"].present?

$redis.set("kinde_m2m_token", result["access_token"], ex: result["expires_in"].to_i)

redirect_to mgmt_path
end

def logout
redirect_to KindeSdk.logout_url, allow_other_host: true
end

def logout_callback
Rails.logger.info("logout callback successfully received")
reset_session
redirect_to root_path
end
end
class AuthController < ApplicationController
def auth
auth = KindeSdk.auth_url
session[:code_verifier] = auth[:code_verifier] if auth[:code_verifier].present?
redirect_to auth[:url], allow_other_host: true
end

def callback
session[:kinde_auth] =
KindeSdk
.fetch_tokens(params["code"], code_verifier: KindeSdk.config.pkce_enabled ? session[:code_verifier] : nil)
.slice(:access_token, :refresh_token, :expires_at)

user_profile = KindeSdk.client(session[:kinde_auth]).oauth.get_user
session[:kinde_user] = user_profile.to_hash

redirect_to root_path
end

def client_credentials_auth
result = KindeSdk.client_credentials_access(
client_id: ENV["KINDE_MANAGEMENT_CLIENT_ID"],
client_secret: ENV["KINDE_MANAGEMENT_CLIENT_SECRET"]
)
raise result if result["error"].present?

$redis.set("kinde_m2m_token", result["access_token"], ex: result["expires_in"].to_i)

redirect_to mgmt_path
end

def logout
redirect_to KindeSdk.logout_url, allow_other_host: true
end

def logout_callback
Rails.logger.info("logout callback successfully received")
reset_session
redirect_to root_path
end
end
Want results from more Discord servers?
Add your server