Пример #1
0
        private void Awake()
        {
#if !UNITY_EDITOR && UNITY_WEBGL
            _service = gameObject.AddComponent <WebGL.WebGLAWSService>();
#else
            _sdk = gameObject.AddComponent <Dotnet.DotnetAWSSDK>();
#endif
        }
        public DeviceAuthenticationMethod(ILogger logger, IDevicePreferences preferences, IAWSSDK aws, string region, string userPoolId, string clientId, string identityPoolId)
        {
            _logger         = logger;
            _preferences    = preferences;
            _aws            = aws;
            _region         = region;
            _userPoolId     = userPoolId;
            _clientId       = clientId;
            _identityPoolId = identityPoolId;

            _cipClient = _aws.CreateCognitoIdentityProviderClient(
                _aws.CreateAnonymousAWSCredentials(),
                _region
                );
        }
 public FacebookAuthenticationMethod(IAWSSDK aws, string identityPoolId, string region)
 {
     _aws            = aws;
     _identityPoolId = identityPoolId;
     _region         = region;
 }
Пример #4
0
        /// <summary>
        /// Creates the CognitoAWSCredentials for accessing AWS resources. Should only be called with an authenticated user.
        /// </summary>
        /// <param name="identityPoolID">The poolID of the identity pool the user belongs to</param>
        /// <param name="identityPoolRegion">The region of the identity pool the user belongs to</param>
        /// <returns>Returns the CognitoAWSCredentials for the user to be able to access AWS resources</returns>
        public ICognitoAWSCredentials GetCognitoAWSCredentials(string identityPoolID, RegionEndpoint identityPoolRegion, IAWSSDK sdk)
        {
            EnsureUserAuthenticated();

            string poolRegion   = UserPool.PoolID.Substring(0, UserPool.PoolID.IndexOf("_"));
            string providerName = "cognito-idp." + poolRegion + ".amazonaws.com/" + UserPool.PoolID;

            ICognitoAWSCredentials credentials = sdk.CreateCognitoAWSCredentials(identityPoolID, identityPoolRegion.SystemName);

            credentials.Clear();
            credentials.AddLogin(providerName, SessionTokens.IdToken);

            return(credentials);
        }