我正在尝试在我的iOS(Swift)应用程序中实现新的AWS Cognito用户池,但我很难让登录过程工作.我基本上试图遵循这里提供的示例.
这是我到目前为止:
AppDelegate中:
class AppDelegate: UIResponder, UIApplicationDelegate, AWSCognitoIdentityInteractiveAuthenticationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let serviceConfiguration = AWSServiceConfiguration(region: AWSRegionType.USEast1, credentialsProvider: nil)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = serviceConfiguration
let configurationUserPool = AWSCognitoIdentityUserPoolConfiguration(
clientId: "###",
clientSecret: "#########",
poolId: "###")
AWSCognitoIdentityUserPool.registerCognitoIdentityUserPoolWithConfiguration(serviceConfiguration, userPoolConfiguration: configurationUserPool, forKey: "UserPool")
self.userPool = AWSCognitoIdentityUserPool(forKey: "UserPool")
self.userPool!.delegate = self
return true
}
func startPasswordAuthentication() -> AWSCognitoIdentityPasswordAuthentication {
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let logInNavigationController = mainStoryboard.instantiateViewControllerWithIdentifier("LogInNavigationController") as! UINavigationController
dispatch_async(dispatch_get_main_queue(), {
self.window?.rootViewController = …Run Code Online (Sandbox Code Playgroud) 我正在尝试为 Javascript 库构建一个 Angular 包装器,但出现“找不到模块”错误。Javascript 库正在开发中,尚未发布到 NPM,所以我使用的是 npm-link,这可能会导致问题,但我不确定。我的 Angular 版本是 8.2.2。
Javascript 源代码库
源库/index.js:
var sourcelib = (function () {
var doSomething = function() {
};
return {
doSomething: doSomething
};
})();
export default sourcelib;
Run Code Online (Sandbox Code Playgroud)
该sourcelib目录还包含的package.json和README.md文件。如您所料,创建了一个 npm-link:
cd sourcelib
npm link
Run Code Online (Sandbox Code Playgroud)
角度包装器
以下是我正在执行以创建 Angular 工作区、库和测试应用程序的 Angular CLI 命令:
ng new app-test --create-application=false
cd app-test
ng generate library testlib
ng generate application testlib-app
Run Code Online (Sandbox Code Playgroud)
现在将testlib链接到 Javascript 库:
cd projects/testlib
npm link sourcelib
Run Code Online (Sandbox Code Playgroud)
在testlib …
我正在尝试使用Lambda生成并返回已签名的cookie,以便我的iOS应用程序可以使用cookie通过CloudFront访问受限文件.
我认为这应该可以使用Signer类:http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudFront/Signer.html
在此基础上,我编写了以下Lambda函数:
var AWS = require('aws-sdk');
var keyPairId = 'APK...';
var privateKey = 'MIIE...';
var signer = new AWS.CloudFront.Signer(keyPairId, privateKey);
exports.handler = function(event, context) {
var options = {url: "https://xxxxxx.cloudfront.net", expires: 1357100000};
signer.getSignedCookie(options, function(err, data) {
if (err) {
context.fail(err);
} else {
context.succeed('Success');
}
});
};
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用.我一直收到错误'在完成请求之前退出流程'.我已经尝试了'options'参数格式的许多排列,但没有任何区别.
任何帮助,将不胜感激.