Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtoshi/cd74f57631805fb1b2290137f58dac9f to your computer and use it in GitHub Desktop.
Save mtoshi/cd74f57631805fb1b2290137f58dac9f to your computer and use it in GitHub Desktop.
require 'jwt'
require 'omniauth/strategies/oauth2'
require 'uri'
# {"error":"invalid_client",
# "error_description":"Client authentication failed(e.g., unknown client, no client auth entication included, or unsupported authentication method)",
# "error_hint":"The OAuth 2.0 Client supports client authentication method \"client_secret_basic\", but method \"client_secret_post\" was requested. You must configure the OAuth 2.0 client's \"token_endpoint_auth_method\" value to accept \"client_secret_post\".",
# "status_code":401}
# How to change token_endpoint_auth_method value to "client_secret_basic"?
# Please change "auth_scheme" value to ":basic_auth".(Default is :request_body)
module OmniAuth
module Strategies
class MyClient < OmniAuth::Strategies::OAuth2
ALLOWED_ISSUERS = ['https://localhost:3000/'].freeze
BASE_SCOPE_URL = 'https://localhost:3000/oauth2/auth'
BASE_SCOPES = %w[profile email openid].freeze
DEFAULT_SCOPE = 'email,profile'
USER_INFO_URL = 'https://localhost:3000/userinfo'
option :name, 'myclient'
option :authorize_options, %i[access_type hd login_hint prompt request_visible_actions scope state redirect_uri include_granted_scopes openid_realm device_id device_name]
option :authorized_client_ids, []
option :client_options,
auth_scheme: :basic_auth, # !!! Default is :request_body !!!
site: 'https://localhost:3000',
authorize_url: 'https://localhost:3000/oauth2/auth',
token_url: 'https://localhost:3000/oauth2/token'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment