Skip to content

Issue with the 'authorization_url' method in Google OAuth flow #4

Description

@erozas

Hey! I'm writing about this issue because while trying to implement the Google OAuth flow as documented in the README, I had an issue with the authorization_url method that's defined in NoPassword::OAuth::GoogleAuthorizationsController.

The current method definition is:

def authorization_url
  AUTHORIZATION_URL.build.query(
    client_id: client_id,
    redirect_uri: callback_url,
    response_type: "code",
    scope: scope,
    state: form_authenticity_token
  )
end

The issue I faced is that I'm getting an "undefined method build for an instance of URI::HTTPS" error, so I had to redefine the authorization_url method with the following to make it work:

def authorization_url
  url = AUTHORIZATION_URL.dup
  url.query = URI.encode_www_form(
    client_id: client_id,
    redirect_uri: callback_url,
    response_type: "code",
    scope: scope,
    state: form_authenticity_token
  )
  url
end

I wonder if this is an acceptable solution.

Thanks for working on the gem, I learned a lot by reading the code by the way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions