question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to pass query params with oauth configuration.

See original GitHub issue

Hello, I am trying to do faderatedSignin by Google/Facebook using oauth and hosted UI. Everything is working fine but after successful signin it’s redirecting back to my redirect url with no query params.

For example, I have signin page with url “http://localhost:3000/?name=xyz”. In the signin component I have added two buttons for Google and Facebook and calling faderatedSignin function with provider. After that it’s redirecting to google/facebook page and I am able to do signin through it. After successful signin it’s redirect back to “http://localhost:3000/”. But I am not able to access query param (?name=xyz). Please check the below code and do the needful.

OAuth configuration:

const awsmobile = {
    "aws_project_region": "XX",
    "aws_cognito_region": "XX",
    "aws_user_pools_id": "XX",
    "aws_user_pools_web_client_id": "XX",
    "oauth": {
        "domain": "XX.amazoncognito.com",
        "scope": [
            "email",
            "openid",
            "profile",
            "aws.cognito.signin.user.admin"
        ],
        "redirectSignIn": "http://localhost:3000/",
        "redirectSignOut": "http://localhost:3000/",
        "responseType": "code"
    },
    "federationTarget": "COGNITO_USER_POOLS"
};

SignIn Component:

import React, { Component } from 'react';
import Amplify, { Auth, Hub } from 'aws-amplify';
import awsmobile from './aws-exports';
Amplify.configure(awsmobile);

class SignIn extends Component {
  
      constructor(props) {
          super(props);
  
          Hub.listen("auth", ({ payload: { event, data } }) => {
            console.log('data:---', data);
            switch (event) {
              case "signIn":
                  console.log('signin:---');
                  break;
              case "signOut":
                  console.log('signout:---');
                  break;
            }
          });
          this.state = {
             
          };
  
      }
  
  
      render() {
        
              return (
                  <div>
                      
                        <button onClick={() => Auth.federatedSignIn({provider: 'Google'})}>Open Google</button>
                        <button onClick={() => Auth.federatedSignIn({provider: 'Facebook'})}>Open Facebook</button>
                        <button onClick={() => Auth.federatedSignIn()}>Open Hosted UI</button>
                        <button onClick={() => Auth.signOut()}>Sign out</button>
                   
                  </div>
              );
          }
        
      }
  

export default SignIn;

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
manueliglesiascommented, Apr 30, 2019

@anis-shaikh I see, this is a good use case for the state param (see AUTHORIZATION endpoint)

Currently, Amplify generates a pseudo-random state for CSRF protection purposes and it is not exposed or modifiable.

I think it would be useful to provide you own state when calling Auth.federatedSignIn().

I am tagging this as a feature request.

0reactions
github-actions[bot]commented, Jun 12, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing custom query parameters in your Application URL ...
The Redirect URI in the loginImplicitGrant MUST ENTIRELY MATCH one of the URIs you have configured under the OAuth client as Authorized Redirect...
Read more >
Pass Parameters to Identity Providers - Auth0
To configure static parameters, call the Auth0 Management API Create a connection or Update a connection endpoint, and pass the upstream_params object in ......
Read more >
Google OAuth Redirect With Query String Possible?
I'm guessing you want to use the query parameter to encode some sort of information that will track the OAuth flow on your...
Read more >
Query Parameter - Ping Identity Support Portal
I would like to set up an IdP ReferenceID adapter "authentication endpoint" so that it will pass a query parameter from the initiating...
Read more >
Adding parameters to the OpenID Connect Authorization URL
So as an example we can send the user directly to the Google login by passing along the query string parameter connection=google-oauth2 ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found