Amplify-cli: Custom domain with OAuth flow?

Created on 16 Jul 2019  路  5Comments  路  Source: aws-amplify/amplify-cli

* Which Category is your question related to? *
Auth

* What AWS Services are you utilizing? *
Cognito

* Provide additional details e.g. code snippets *
I have a successful OAuth flow working, however, when going through the flow with Google it is showing, do you want to authorize amazoncognito.com, instead of my domain name. I tried using the CLI "amplify auth update" but that doesn't let me specify a custom domain. Is there a way to specify that custom domain outside of manually in the AWS console?

auth question

Most helpful comment

This temporary workaround will allow me to not lose updates to aws_exports:

import aws_exports from '@/aws-exports'

var my_exports = JSON.parse(JSON.stringify(aws_exports))
my_exports.oauth.domain = 'auth.mysite.com'
Amplify.configure(my_exports)

Testing this, but I believe this will work.

All 5 comments

When you do amplify auth update, did you select Walkthrough all the auth configurations? This should have you step through all configurable values, and will lead you to a question about OAuth flow. If you say 'yes' to the OAuth question, the CLI will subsequently show a question asking you to enter your domain.

I do get prompted for a "name", but it's not a domain name, the CLI makes the OAuth endpoint something like "mysite-beta.auth.us-east-1.amazoncognito.com". I would prefer instead to simply have "auth.mysite.com". I can only do that by manually configuring awsexports and setting the custom domain in Cognito.

This temporary workaround will allow me to not lose updates to aws_exports:

import aws_exports from '@/aws-exports'

var my_exports = JSON.parse(JSON.stringify(aws_exports))
my_exports.oauth.domain = 'auth.mysite.com'
Amplify.configure(my_exports)

Testing this, but I believe this will work.

@cliffordh Unfortunately, Cognito appends the "auth.us-east-1.amazoncognito.com" domain to your provided domain name - which is the behavior on the cognito console as well.

@cliffordh works for me .. really wish there was a way to specify the full domain not just prefix in settings to avoid this hacky method for something fairly common ..

Was this page helpful?
0 / 5 - 0 ratings