-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use authentication from AWSCognitoIdentityProvider with Amplify #3832
Comments
|
Thanks for your reply! This is less of an individual snippet thing and more of a complete API change from what I can see, but perhaps there’s something I’m missing. At the moment we have various files that import It could be that we don’t have a choice and that to use Amplify we need to rewrite those files to use a new way, but I was hoping maybe there’s something was a back door for use to keep all our existing auth logic and just provide Amplify with the output/token for the use of GraphQL. Thanks again for responding to my question/issue. |
Unfortunately, you would need to rewrite those classes in order to use |
So there is actually a way around this so that we can provide a token! It's outlined in this doc page: https://docs.amplify.aws/gen1/swift/build-a-backend/graphqlapi/customize-authz-modes/#aws-lambda-1 For anyone viewing this conversation: class MyAPIAuthProviderFactory: APIAuthProviderFactory {
let myAuthProvider = MyFunctionAuthProvider()
override func functionAuthProvider() -> AmplifyFunctionAuthProvider? {
return MyFunctionAuthProvider()
}
}
class MyFunctionAuthProvider : AmplifyFunctionAuthProvider {
func getLatestAuthToken() async throws -> String {
....
}
}
try Amplify.add(plugin: AWSAPIPlugin(apiAuthProviderFactory: MyAPIAuthProviderFactory()))
try Amplify.configure() |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Is your feature request related to a problem? Please describe.
We are currently migrating from AWSAppSync to Amplify's AWSAPIPlugin as AWSAppSync is in maintenance mode and support will be dropped soon. We currently use AWSCognitoIdentityProvider for all the authentication in the app and have a lot of custom code written around this that we would like to continue to use as it handles things outside of the AWSAppSync part. Is there a way to use the token/authentication from AWSCognitoIdentityProvider with Amplify rather than AWSCognitoAuthPlugin so that we can just use the AWSAPIPlugin part of Amplify without rewriting all of our authentication layer?
Describe the solution you'd like
Being able to provide Amplify with a token gathered elsewhere for authentication rather than scrapping all our authentication layer and switching to AWSCognitoAuthPlugin.
Describe alternatives you've considered
Is the feature request related to any of the existing Amplify categories?
API, Auth
Additional context
No response
The text was updated successfully, but these errors were encountered: