Unable to get my App id for parse - ios

I am using www.parse.com for an xcode project. Since they do not allow new sign ups, so how do I get my application id for the following code in order to use their services:
let configuration = ParseClientConfiguration {
$0.applicationId = "YOUR_APP_ID"
$0.server = "http://YOUR_PARSE_SERVER:1337/parse"
}
Parse.initializeWithConfiguration(configuration)

Related

Redirect all DNS requests to custom resolver in iOS app

everyone.
I am trying to override dns resolver settings in my iOS app.
I used NEVPNManager to install a personal vpn and then used onDemandRules to set specific dns servers.
So far my code works for some domains.
Below is my code.
When I put "*.com" in matchDomains, it works perfectly.
But what I want to do is to redirect all dns queries to specific dns server.
I tried empty matchDomains([]) and empty string([""]).
I also tried wildcard expression like ["*"] and ["*.*].
So far I had no success.
It's been a few days and I still can't figure it out.
Can anybody tell me what I am missing here?
Thanks in advance.
let manager = NEVPNManager.sharedManager()
manager.loadFromPreferencesWithCompletionHandler { error in
if let vpnError = error {
print("vpn error in loading preferences : \(vpnError)")
return
}
if manager.protocolConfiguration == nil {
let myIPSec = NEVPNProtocolIPSec()
myIPSec.username = "username"
myIPSec.serverAddress = "server address"
myIPSec.passwordReference = self.getPersistentRef()
myIPSec.authenticationMethod = NEVPNIKEAuthenticationMethod.SharedSecret
myIPSec.sharedSecretReference = self.getPersistentRef()
myIPSec.useExtendedAuthentication = true
manager.protocolConfiguration = myIPSec
manager.localizedDescription = "myDNS"
let evaluationRule = NEEvaluateConnectionRule(matchDomains: ["*.com"], andAction: NEEvaluateConnectionRuleAction.ConnectIfNeeded)
evaluationRule.useDNSServers = ["XXX.XXX.XXX.XXX"]
let onDemandRule = NEOnDemandRuleEvaluateConnection()
onDemandRule.connectionRules = [evaluationRule]
onDemandRule.interfaceTypeMatch = NEOnDemandRuleInterfaceType.Any
manager.onDemandRules = [onDemandRule]
manager.onDemandEnabled = true
manager.enabled = true
manager.saveToPreferencesWithCompletionHandler { error in
if let vpnError = error {
print("vpn error in saving preferences : \(vpnError)")
return
}
}
}
}
I found this is buggy in even the latest iOS (10.3.1) and using NEVPNProtocolIKEv2. One moment it works, the next moment it doesn't want to start a VPN connection because it seems to misinterpret the ondemand rules and gives the error back saying the VPN profile is not enabled. I ended up with configuring the IKEv2 server (Strongswan) to push DNS settings with the "rightdns" option in /etc/ipsec.conf. This gives me the desired result of having the DNS requests redirected to a custom resolver.

APPID and CLIENTKEY in ios apps after deploying parse server to AWS

I deployed a parse server to AWS Elastic Beanstalk and rewrite my iOS app in AppDelegate.swift. But i only rewrited the ParseMutableClientConfiguration.server so, the APPID and CLIENTKEY is still the same ID and KEYS that are in parse.api.com
It this a correct way to configure my ID and KEYS and server? or do i need to generate a new APPID by myself in this case?
let config = ParseClientConfiguration(block: {
(ParseMutableClientConfiguration) -> Void in
ParseMutableClientConfiguration.applicationId = APP_ID;
ParseMutableClientConfiguration.clientKey = CLIENT_ID;
ParseMutableClientConfiguration.server = "EC2 DNS"
});
Parse.initializeWithConfiguration(config)
Yes this is fine. With swift 3 its done like this.
// Init Parse
let configuration = ParseClientConfiguration {
$0.applicationId = "XXX"
$0.clientKey = "XXX"
$0.server = "XXX"
$0.isLocalDatastoreEnabled = true
}
Parse.initialize(with: configuration)

How to set custom endpoints in amazon ios sdk for presigning urls?

I am trying to get presigned url for these music files from amazon server , I have working code of android but couldn't find a way in Objective-C to do this.
public static String getPreSignedURL(String url) {
java.util.Date expiration = new java.util.Date();
long msec = expiration.getTime();
msec += 1000 * 60 * 5; // 5 minutes
expiration.setTime(msec);
AWSCredentials myCredentials = new BasicAWSCredentials(
AppConstants.AWS_ACCESS_KEY_ID, AppConstants.AWS_SECRET_KEY_ID);
AmazonS3 s3client = new AmazonS3Client(myCredentials);
s3client.setEndpoint(AppConstants.ENDPOINT_S3);
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(
AppConstants.BUCKET_NAME, url.replace(AppConstants.OBJECT_NAME_FILTER, ""));
request.setExpiration(expiration);
URL objectURL = s3client.generatePresignedUrl(request);
return objectURL.toString();
}
This above code is in android.
var presignedUrl: AWSTask = AWSTask()
let expiration = NSDate().dateByAddingTimeInterval(5*60)
let credential = AWSStaticCredentialsProvider.init(accessKey: AWS_ACCESS_KEY_ID, secretKey: AWS_SECRET_KEY_ID)
let configuration = AWSServiceConfiguration.init(region:.USEast1, credentialsProvider: credential)
//print("%#",configuration.endpoint)
//let regionTp = AWSRegionType(s)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration
let urlBuilder = AWSS3PreSignedURLBuilder.defaultS3PreSignedURLBuilder()
let preSignedURLRequest = AWSS3GetPreSignedURLRequest.init()
preSignedURLRequest.key = "10488/01-New_Jack_City_hq.mp3"
preSignedURLRequest.bucket = "damixhub"
preSignedURLRequest.expires = expiration
preSignedURLRequest.HTTPMethod = .GET
presignedUrl = urlBuilder.getPreSignedURL(preSignedURLRequest)
This is what I am doing in ios till now but urls have significant difference and I get accessdenied error possibly because I havent mentioned custom end points.
Please let me know if you know solution to this.
I managed to get this using version 1 of amazon sdk.
Just write pod "AWSiOSSDK" if you are using cocoa pods , if you want to do it manually then you need to get it from github get it here
Note - As amazon doesnt provide this functionality in version 2 of sdk I have to use this deprecate version.

Google API Calender v3 Event Insert via Service Account using Asp.Net MVC

I have been trying to insert a Google calendar event via Google service account that was created for an app in my dev console, but I am continually getting a helpless 404 response back on the Execute method. In the overview of the dev console I can see that the app is getting requests because there are instances of errors on the calendar.events.insert method. There is no information on what is failing. I need this process to use the Service account process instead of OAuth2 so as to not require authentication each time a calendar event needs to be created.
I have set up the service account, given the app a name, have the p12 file referenced in the project. I've also, gone into a personal calendar and have shared with the service account email address. Also, beyond the scope of this ticket, I have created a secondary app, through an administration account and have granted domain wide access to the service account only to receive the same helpless 404 error that this is now giving.
Error Message: Google.Apis.Requests.RequestError
Not Found [404]
Errors [Message[Not Found] Location[ - ] Reason[notFound] Domain[global]
Any help identifying a disconnect or error would be greatly appreciated.
var URL = #"https://www.googleapis.com/calendar/v3/calendars/testcalendarID.com/events";
string serviceAccountEmail = "createdserviceaccountemailaq#developer.gserviceaccount.com";
var path = Path.Combine(HttpRuntime.AppDomainAppPath, "Files/myFile.p12");
var certificate = new X509Certificate2(path, "notasecret",
X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { Google.Apis.Calendar.v3.CalendarService.Scope.Calendar },
}.FromCertificate(certificate));
BaseClientService.Initializer initializer = new
BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Test App"
};
Google.Apis.Calendar.v3.CalendarService calservice = new Google.Apis.Calendar.v3.CalendarService(initializer);
string timezone = System.TimeZone.CurrentTimeZone.StandardName;
var calendarEvent = new Event()
{
Reminders = new Event.RemindersData()
{
UseDefault = true
},
Summary = title,
Description = description,
Location = location,
Start = new EventDateTime()
{
//DateTimeRaw = "2014-12-24T10:00:00.000-07:00",
DateTime = startDateTime,
TimeZone = "America/Phoenix"
},
End = new EventDateTime()
{
//DateTimeRaw = "2014-12-24T11:00:00.000-08:00",
DateTime = endDateTime,
TimeZone = "America/Phoenix"
},
Attendees = new List<EventAttendee>()
{
new EventAttendee()
{
DisplayName = "Joe Shmo",
Email = "joeshmoemail#email.com",
Organizer = false,
Resource = false
}
}
};
var insertevent = calservice.Events.Insert(calendarEvent, URL);
var requestedInsert = insertevent.Execute();
I had the same problem. The solution was to add an email client, whose calendar event you want to send.
Credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = Scopes,
User = "example_client_email#gmail.com"
}.FromCertificate(certificate));
So I found out that for this to work, You need to make sure that you access the google.Admin account for referencing the service account Client ID of the app you created.
Another thing that helps is making sure the timezone is in the following format "America/Phoenix"
I have now successfully created events through the service account WITHOUT authentication.

MonoTouch SecKeyChain.Add returning SecStatusCode.Param

I'm trying to save a record like so:
var testRecord = new SecRecord(SecKind.GenericPassword)
{
CreationDate = DateTime.UtcNow,
MatchCaseInsensitive = false,
Service = "MyService",
Label = "MyService",
Account = "User",
Generic = NSData.FromString("test", NSStringEncoding.UTF8),
};
SecKeyChain.Add(testRecord);
...but I'm getting SecStatusCode.Param back when I run it in the simulator. According to the documentation, that code means "Invalid or incomplete parameters passed" but I don't see anything missing or unusual that others aren't doing with apparent success.
Even adding CreationDate, Invisible, Description, Comment, Accessible, and ValueData properties to the SecRecord (some as in this example) didn't help -- still getting SecStatusCode.Param.
Are there any non-obvious things that might cause a Param status code to be returned?
I had a lot of trouble trying to use the keychain. I finally got mine working to store user credentials in the app. Here is what I have:
SecRecord existingRec = new SecRecord (SecKind.GenericPassword) {
Service = Keychain.USER_SERVICE,
Label = Keychain.USER_LABEL
};
var record = new SecRecord (SecKind.GenericPassword) {
Service = Keychain.USER_SERVICE,
Label = Keychain.USER_LABEL,
Account = username,
ValueData = NSData.FromString (password),
Accessible = SecAccessible.Always
};
SecStatusCode code = SecKeyChain.Add (record);
if (code == SecStatusCode.DuplicateItem) {
code = SecKeyChain.Remove (existingRec);
if (code == SecStatusCode.Success)
code = SecKeyChain.Add (record);
}
Keychain is a static class with constants so I don't have to retype the strings.
The only thing different between yours and mine is the CreationDate/MatchCaseInsensitive properties and the encoding for NSData. Maybe try it without those and see if it works? If so, add them back separately and see what gives the problem.
This might be because you are running on the simulator - in that case you need to add an Entitlements plist in the project options for your current build config in order to make keychain access work.

Resources