1661818440
Google Directions API SDK for iOS, entirely written in Swift.
PXLocation.googlePlaceId("gplaceid")
, or PXLocation.googlePlaceId(gmsPlace.placeID)
if you're already using Google's Places SDK for iOS)trafficModel
property on the PXGoogleDirections
class to match Google's one in the API (recently added); it works only for driving routes, and when a departure date is specifieddrawOnMap
method of the PXGoogleDirectionsRoute
classTo use PXGoogleDirections in your project add the following line to your Cartfile
:
github "Poulpix/PXGoogleDirections"
Alternatively, if you wish to target a specific version of the library, simply append it at the end of the line in the
Carttfile
, e.g.:github "Poulpix/PXGoogleDirections" ~> 1.5
.
Then run the following command from the Terminal:
carthage update
Finally, back to Xcode, drag & drop the generated framework in the "Embedded Binaries" section of your target's General tab. The framework should be located in the Carthage/Build/iOS
subfolder of your Xcode project.
Important: Carthage is only supported starting from version 1.4 of this library. Previous versions of this library will not work.
To use PXGoogleDirections in your project add the following Podfile
to your project:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.3'
use_frameworks!
pod 'PXGoogleDirections'
Then run the following command from the Terminal:
pod install
Important: If your project needs both PXGoogleDirections and Google Maps and/or Google Places iOS SDK, you will run into problems. Please see the "Compatibility with Google pods" paragraph below, and do not hesitate to contact me and describe your issue if you require assistance!
Building from raw source code is the preferred method if you wish to avoid known issues with the Google Maps iOS SDK conflicts with the library. However, you'll be lacking the automation and version updates the Cocoapods and Carthage frameworks provide.
To build from source, follow these simple steps:
PXGoogleDirections
project to your own Xcode projectPXGoogleDirections
project (PXGoogleDirections.framework
) to the "Embedded Binaries" section of your Xcode project's main targetQuick-start in two lines of Swift code:
import PXGoogleDirections
2. Create an API object:
let directionsAPI = PXGoogleDirections(apiKey: "<insert your Google API key here>",
from: PXLocation.coordinateLocation(CLLocationCoordinate2DMake(37.331690, -122.030762)),
to: PXLocation.specificLocation("Googleplex", "Mountain View", "United States"))
3. Run the Directions request:
directionsAPI.calculateDirections({ response in
switch response {
case let .error(_, error):
// Oops, something bad happened, see the error object for more information
break
case let .success(request, routes):
// Do your work with the routes object array here
break
}
})
Important: You normally don't need to call
GMSServices.provideAPIKey()
yourself: it will be called by PXGoogleDirections when initializing the SDK.
See "Documentation" below for more information on the available properties and response data.
The SDK provides an integrated documentation within Xcode, with full autocomplete support.
To help getting you started, a sample project is also available in the "Sample" subfolder of this repository.
It is designed to demo the main features of both the API and the SDK.
Since V1.3, PXGoogleDirections uses Google's latest branch of Google Maps iOS SDK, which has now been split into smaller, more modular frameworks. PXGoogleDirections has a dependency with three of them:
GoogleMapsCore
GoogleMapsBase
GoogleMaps
The Google Places iOS SDK is not required.
If your app also requires the Google Maps iOS SDK (for drawing on a map, for example), you will run into troubles because of conflicts with the bundled Google Maps iOS SDK in the pod. This is because of Google's way of releasing its pods as static frameworks, and not dynamic ones.
Here is the only workaround known to date:
pod update
.pod GoogleMaps
, pod GooglePlaces
) and issue a pod update
.git submodule add https://github.com/poulpix/PXGoogleDirections.git Frameworks/External/PXGoogleDirections
This will download all of the PXGoogleDirections project in a subfolder of your own project (Frameworks/External/PXGoogleDirections
). Of course you can change this path if you like.
Important: You may also request a specific version of the framework by adding the
-b <branch>
switch to thegit submodule
command, like this:
git submodule add -b <branch> https://github.com/poulpix/PXGoogleDirections.git Frameworks/External/PXGoogleDirections
To find out the appropriate branch name, check out all the available branches on Github
4. Update your Podfile to give instructions on how to build both your project and the PXGoogleDirections submodule:
source 'https://github.com/CocoaPods/Specs.git'
workspace 'test.xcworkspace' # Your project's workspace
project 'test.xcodeproj' # Your project's Xcode project
project 'Frameworks/External/PXGoogleDirections/PXGoogleDirections.xcodeproj' # Update folder structure if needed
target 'test' do
project 'test.xcodeproj'
platform :ios, '10.0' # Update for your needs
use_frameworks!
# Update these lines depending on which Google pods you need
pod 'GoogleMaps'
pod 'GooglePlaces'
# Other pods...
end
# This tells Cocoapods how to build the subproject
target 'PXGoogleDirections' do
project 'Frameworks/External/PXGoogleDirections/PXGoogleDirections.xcodeproj'
platform :ios, '9.3'
pod 'GoogleMaps'
end
5. Now you need to do a pod install
in two locations:
Frameworks/External/PXGoogleDirections
).
6. Open Xcode with your project.xcworkspace and build the PXGoogleDirections target, then your app's target. Everything should build properly.
Depending on your setup, you might see one or several of these known issues:
Lots of messages like these at runtime (usually application startup): Class GMSxxx_whatever is implemented in both (name of your app) and (reference to PXGoogleDirections framework). One of the two will be used. Which one is undefined.
This is because with Carthage or Cocoapods you usually have two versions of the Google Maps iOS SDK : the one that has been linked with the PXGoogleDirections library, and the one you will be forced to link against in your own application if you wish to use it explicitly. From what I've seen, there is no real impact to these warnings as long as both versions are equivalent. They only pollute your output console at runtime.
Messages like these at runtime (usually when showing a Google Maps view): Main Thread Checker: UI API called on a background thread: -[UIApplication setNetworkActivityIndicatorVisible:]
This behavior is new to Xcode 9, and it seems like the culprit is the Google Maps iOS SDK itself, not the sample app provided with the library. These messages are not really harmful, but they are not sane either. If you find a solution, please PM me!
The framework is not yet ready for Swift Package Manager since it requires static linking to Google Maps iOS SDKs and inclusion of a Google Maps resources bundle; both of those tasks can't be done with Swift Package Manager at this time.
The PXGoogleDirections SDK is licensed under the New BSD license. (see LICENSE for more information.)
Don't hesitate to drop me a line on Github, Twitter, Stack Overflow, or by email:
Author: poulpix
Source code: https://github.com/poulpix/PXGoogleDirections
License: BSD-3-Clause license
#swift
1595396220
As more and more data is exposed via APIs either as API-first companies or for the explosion of single page apps/JAMStack, API security can no longer be an afterthought. The hard part about APIs is that it provides direct access to large amounts of data while bypassing browser precautions. Instead of worrying about SQL injection and XSS issues, you should be concerned about the bad actor who was able to paginate through all your customer records and their data.
Typical prevention mechanisms like Captchas and browser fingerprinting wonāt work since APIs by design need to handle a very large number of API accesses even by a single customer. So where do you start? The first thing is to put yourself in the shoes of a hacker and then instrument your APIs to detect and block common attacks along with unknown unknowns for zero-day exploits. Some of these are on the OWASP Security API list, but not all.
Most APIs provide access to resources that are lists of entities such as /users
or /widgets
. A client such as a browser would typically filter and paginate through this list to limit the number items returned to a client like so:
First Call: GET /items?skip=0&take=10
Second Call: GET /items?skip=10&take=10
However, if that entity has any PII or other information, then a hacker could scrape that endpoint to get a dump of all entities in your database. This could be most dangerous if those entities accidently exposed PII or other sensitive information, but could also be dangerous in providing competitors or others with adoption and usage stats for your business or provide scammers with a way to get large email lists. See how Venmo data was scraped
A naive protection mechanism would be to check the take count and throw an error if greater than 100 or 1000. The problem with this is two-fold:
skip = 0
while True: response = requests.post('https://api.acmeinc.com/widgets?take=10&skip=' + skip), headers={'Authorization': 'Bearer' + ' ' + sys.argv[1]}) print("Fetched 10 items") sleep(randint(100,1000)) skip += 10
To secure against pagination attacks, you should track how many items of a single resource are accessed within a certain time period for each user or API key rather than just at the request level. By tracking API resource access at the user level, you can block a user or API key once they hit a threshold such as ātouched 1,000,000 items in a one hour periodā. This is dependent on your API use case and can even be dependent on their subscription with you. Like a Captcha, this can slow down the speed that a hacker can exploit your API, like a Captcha if they have to create a new user account manually to create a new API key.
Most APIs are protected by some sort of API key or JWT (JSON Web Token). This provides a natural way to track and protect your API as API security tools can detect abnormal API behavior and block access to an API key automatically. However, hackers will want to outsmart these mechanisms by generating and using a large pool of API keys from a large number of users just like a web hacker would use a large pool of IP addresses to circumvent DDoS protection.
The easiest way to secure against these types of attacks is by requiring a human to sign up for your service and generate API keys. Bot traffic can be prevented with things like Captcha and 2-Factor Authentication. Unless there is a legitimate business case, new users who sign up for your service should not have the ability to generate API keys programmatically. Instead, only trusted customers should have the ability to generate API keys programmatically. Go one step further and ensure any anomaly detection for abnormal behavior is done at the user and account level, not just for each API key.
APIs are used in a way that increases the probability credentials are leaked:
If a key is exposed due to user error, one may think you as the API provider has any blame. However, security is all about reducing surface area and risk. Treat your customer data as if itās your own and help them by adding guards that prevent accidental key exposure.
The easiest way to prevent key exposure is by leveraging two tokens rather than one. A refresh token is stored as an environment variable and can only be used to generate short lived access tokens. Unlike the refresh token, these short lived tokens can access the resources, but are time limited such as in hours or days.
The customer will store the refresh token with other API keys. Then your SDK will generate access tokens on SDK init or when the last access token expires. If a CURL command gets pasted into a GitHub issue, then a hacker would need to use it within hours reducing the attack vector (unless it was the actual refresh token which is low probability)
APIs open up entirely new business models where customers can access your API platform programmatically. However, this can make DDoS protection tricky. Most DDoS protection is designed to absorb and reject a large number of requests from bad actors during DDoS attacks but still need to let the good ones through. This requires fingerprinting the HTTP requests to check against what looks like bot traffic. This is much harder for API products as all traffic looks like bot traffic and is not coming from a browser where things like cookies are present.
The magical part about APIs is almost every access requires an API Key. If a request doesnāt have an API key, you can automatically reject it which is lightweight on your servers (Ensure authentication is short circuited very early before later middleware like request JSON parsing). So then how do you handle authenticated requests? The easiest is to leverage rate limit counters for each API key such as to handle X requests per minute and reject those above the threshold with a 429 HTTP response.
There are a variety of algorithms to do this such as leaky bucket and fixed window counters.
APIs are no different than web servers when it comes to good server hygiene. Data can be leaked due to misconfigured SSL certificate or allowing non-HTTPS traffic. For modern applications, there is very little reason to accept non-HTTPS requests, but a customer could mistakenly issue a non HTTP request from their application or CURL exposing the API key. APIs do not have the protection of a browser so things like HSTS or redirect to HTTPS offer no protection.
Test your SSL implementation over at Qualys SSL Test or similar tool. You should also block all non-HTTP requests which can be done within your load balancer. You should also remove any HTTP headers scrub any error messages that leak implementation details. If your API is used only by your own apps or can only be accessed server-side, then review Authoritative guide to Cross-Origin Resource Sharing for REST APIs
APIs provide access to dynamic data thatās scoped to each API key. Any caching implementation should have the ability to scope to an API key to prevent cross-pollution. Even if you donāt cache anything in your infrastructure, you could expose your customers to security holes. If a customer with a proxy server was using multiple API keys such as one for development and one for production, then they could see cross-pollinated data.
#api management #api security #api best practices #api providers #security analytics #api management policies #api access tokens #api access #api security risks #api access keys
1601381326
Weāve conducted some initial research into the public APIs of the ASX100 because we regularly have conversations about what others are doing with their APIs and what best practices look like. Being able to point to good local examples and explain what is happening in Australia is a key part of this conversation.
The method used for this initial research was to obtain a list of the ASX100 (as of 18 September 2020). Then work through each company looking at the following:
With regards to how the APIs are shared:
#api #api-development #api-analytics #apis #api-integration #api-testing #api-security #api-gateway
1616839708
Are you looking for the best swift iOS App Development Company in USA & India? We at AppClues Infotech is one of the leading Swift iOS App development company that help to build Innovative, Secure & high-performance mobile app with modern features & technology.
For more info:
Website: https://www.appcluesinfotech.com/
Email: info@appcluesinfotech.com
Call: +1-978-309-9910
#swift ios app development company in usa & india #swift ios app development company in usa #hire swift ios app developers in usa #top swift ios app development company #best swift ios app development company in usa #app development company in usa & india
1604399880
Iāve been working with Restful APIs for some time now and one thing that I love to do is to talk about APIs.
So, today I will show you how to build an API using the API-First approach and Design First with OpenAPI Specification.
First thing first, if you donāt know whatās an API-First approach means, it would be nice you stop reading this and check the blog post that I wrote to the Farfetchs blog where I explain everything that you need to know to start an API using API-First.
Before you get your hands dirty, letās prepare the ground and understand the use case that will be developed.
If you desire to reproduce the examples that will be shown here, you will need some of those items below.
To keep easy to understand, letās use the Todo List App, it is a very common concept beyond the software development community.
#api #rest-api #openai #api-first-development #api-design #apis #restful-apis #restful-api
1598083582
As more companies realize the benefits of an API-first mindset and treating their APIs as products, there is a growing need for good API product management practices to make a companyās API strategy a reality. However, API product management is a relatively new field with little established knowledge on what is API product management and what a PM should be doing to ensure their API platform is successful.
Many of the current practices of API product management have carried over from other products and platforms like web and mobile, but API products have their own unique set of challenges due to the way they are marketed and used by customers. While it would be rare for a consumer mobile app to have detailed developer docs and a developer relations team, youāll find these items common among API product-focused companies. A second unique challenge is that APIs are very developer-centric and many times API PMs are engineers themselves. Yet, this can cause an API or developer program to lose empathy for what their customers actually want if good processes are not in place. Just because youāre an engineer, donāt assume your customers will want the same features and use cases that you want.
This guide lays out what is API product management and some of the things you should be doing to be a good product manager.
#api #analytics #apis #product management #api best practices #api platform #api adoption #product managers #api product #api metrics