-
Notifications
You must be signed in to change notification settings - Fork 62
Integration of basic authentication to User Pool #27
Comments
It isn't supported in this. One user posted some code here that gave me a jump no connecting using user pools though.
EDIT: |
Ok I was able to use AWSRNCognitoCredentials with the CognitoUserPool backing. JS bugThe listener.addListener("LoginsRequestedEvent", async ({callbackId}) => { You might get some odd JSON errors from RCTConvert if you don't make this change. Basically the event raised from the native code is WorkflowFirst, you need to authenticate against the user pool and pull the Once you have that, you need to use that token for using the federated identity flow.
Checking it outOn IOS I made these calls and they worked once I figured out all that other junk: const fetchedId = await AWSCognitoCredentials.getCredentialsAsync()
console.log('called getCredentialsAsync', fetchedId)
//this doesnt
console.log('calling getIdentityIDAsync')
const fetchedId2 = await AWSCognitoCredentials.getIdentityIDAsync()
console.log('called getIdentityIDAsync', fetchedId2) I confirmed that my {
"AccessKey": <hash>,
"Expiration": <datetime>,
"SecretKey": <hash>,
"SessionKey": <hash>
} And the Deprecated usage of
|
I find this use case very basic. |
@lielran the first drop of this SDK isnt concerned with the UserPool portion, but rather the Cognito Identity Provider side of the story which isnt concerned about login/logout. |
Hello, Unfortunately, at the very end, I could not load the module, the third does not recognize './Cognito'.
I will post as soon as I am able to get the token; In the meantime, if anyone was able to make the native bridge working, I'd be glad to hear how to did it :) |
@MathieuMailhos there is a missing bit in the Java stuff from that download. Follow the ReactNative docs for creating Native bridges for Android. Specifically make sure your MainActivity and MainApplication files have properly registered the module. |
Yes! So I started to add the missing jars from the SDK:
I updated
I created the folder in
After all of that, I had a nicely compiling project (which means that package is well-loaded).
I have a big doubt about |
Ah..that's wrong. The module is found at `NativeModules.Cognito`.
So you can `const { Cognito } = NativeModules` and that should werk
…On Sat, Jan 7, 2017 at 3:38 PM, Mathieu ***@***.***> wrote:
Yes!
So I started to add the missing jars from the SDK:
$ ls android/app/libs/
aws-android-sdk-cognito-2.3.8.jar
aws-android-sdk-core-2.3.8.jar
aws-android-sdk-cognitoidentityprovider-2.3.8.jar
I updated MainApplication.java with:
import com.rctcognito.RCTCognitoPackage;
// and later in the List<ReactPackage>
new RCTCognitoPackage(),
I created the folder in src/main/java/com/rctcognito which includes:
AppHelper.java
Cognito.java (both from the AWS topic)
and RCTCognitoPackage.java, which is the Reat module:
package com.rctcognito;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class RCTCognitoPackage implements ReactPackage {
@OverRide
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
@OverRide
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
@OverRide
public List<NativeModule> createNativeModules( ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new Cognito(reactContext));
return modules;
}
}
After all of that, I had a nicely compiling project (which means that
package is well-loaded).
I Just had a problem to import it when doing:
import { NativeModules } from 'react-native';
module.exports = NativeModules.ToastAndroid;
import Cognito from './Cognito';
I have a big doubt about ./Cognito syntax
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAsC3I1tM18B7Om2J5U8QDd0sn5EY4Nks5rQBPvgaJpZM4LJrt4>
.
|
@mnichols - I found it strange that the basic part is not supported(get a token) while the advanced is shown in the examples. also, the solution above is valid for Android,right? what about wrapping all aws apis via some v4 wrapper(e.g. https://github.com/leimd/react-native-aws-signature ) |
The idToken you get from Cognito's identity provider is what you use to
connect to AWS services. The way you obtain that idToken depends on how you
have integrated your Cognito Identity Pool with your identity provider
(Cognito User Pool, Facebook, whatever...). As far as refresh tokens with
the REST api and so on...I don't know because I am using their SDK directly
so haven't really needed to use the raw api, but I am sure it is possible.
…On Mon, Feb 6, 2017 at 3:41 PM, Mathieu ***@***.***> wrote:
@mnichols <https://github.com/mnichols>
I was able to succesfuly logon with Facebook on my App and to get:
{
"AccessKey": <hash>,
"Expiration": <datetime>,
"SecretKey": <hash>,
"SessionKey": <hash>
}
{ identityId: "<region>:<uuid>" }
However, I still have a question. How do I validate, on a remote REST API,
that those credentials are valid?
I do not see any Credentials.validate() in any SDK.
It seems that I need to use this credential object and use it against an
AWS service pretty much anything right?
Thank you very much
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAsC48dZ5xtZQhMfPFCZvHRlzBBCEM_ks5rZ6GEgaJpZM4LJrt4>
.
|
@mnichols I am trying to get the token from the user pool. I don't know where i have lost. I can't able to create a user in the pool(Users and groups). Kindly provide any sample code to get the token. I am following this link https://medium.com/@thexap/user-authentication-with-react-native-and-amazon-cognito-982cca085916 |
Hello,
How can I do a basic authentication (e.g. get access token) to a user pool on Cognito ?
All I was able to see in the repo was connections to Identity Providers (such as Facebook...).
Thanks!
The text was updated successfully, but these errors were encountered: