places not found using google places api in iOS - ios

I am trying to show nearby places with selected types
types - Bar, Cafe, ATM etc
I have created project on developer console.
enable API (google places api, google map sdk, direction api)
I have created iOS api keys but Api key not working. I got this error message
This IP, site or mobile application is not authorized to use this API
key. Request received from IP address 114.143.244.10, with empty
referer
When I tried browser api key I got this error
This API project is not authorized to use this API.
Please ensure that this API is activated in the APIs Console: Learn
more: https://code.google.com/apis/console
I am using this url
NSString *url = [NSString stringWithFormat:#"https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&radius=%#&types=%#&sensor=true&key=%#",
currentCentre.latitude,
currentCentre.longitude,
[NSString stringWithFormat:#"%i", currenDist],
googleType,
kGOOGLE_API_KEY
];
I didn't get what is the problem.

Enable to this api Google Places API Web Service & Google Places API for iOS in the APIs Console
Refer to this document....
Google Places API Web Service
https://developers.google.com/places/webservice/search

Please Check Your All API are Enable On The Google Developer Console
Step 1 Go to Developer Console
Step 2 API Manager ==> API Library ==> Google Maps APIs ==> More
Step 3 And Enable ==> Google Places API Web Service
(AutoComplete and Seaching)
Step 4 Done Enjoy (^_^) ALl Is Done !!!!
NOTE:- Make Sure Your API KEY is Proper and Created Okay ....

I think i know your problem now, it possible that you missed a step..
the steps are suppose to be:
1) Go to Developer Console https://code.google.com/apis/console/
2) In the Credentials, under Public API Access , Create New key
3) Select the server key from the option.
4) Enter your IP Address on the field and if you have more ip addresses, you can just add on every single line.NOTE: Enter the IP Address only when you want to use it for your testing purpose. Else leave the IP Address section blank.
5) Once you are done, click create and your new Server Key will be generated and you can then add that server key to your URL.
use it like:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=[lat],[lon]&radius=[radius]&key=kGOOGLE_API_KEY&sensor=true
or from the tutorial that you are using..
https://maps.googleapis.com/maps/api/place/search/json?location=[lat],[lon]&radius=[radius]&types=[type]&key=kGOOGLE_API_KEY&sensor=true
as you can see &sensor=true is the last parameter..(don't trust anything on the internet).. hahaha..
everything must have been working if you have followed, carefully.. i suggest do it from the top.. hahaha.. Lols.. you'll know and learn what's missing/forgotten, and that'll help you be a better person.. Lols.. Good luck sir.. :)

Try to use this library https://github.com/FuerteInternational/FTGooglePlacesAPI with your key and let me know.

Related

iOS GoogleMap API key, If keep it as blank will be generated any issue?

I have just simple question. I'm using goole map and direction API. So I need to create API key thats fine, I have done it.
But When I edit my API key and select Application restrictions to iOS Apps and save it.
I'm using this key in my app then I'm getting below error message.
This IP, site or mobile application is not authorized to use this API key. Request received from IP address XXX.XXX.XX.XXX, with empty referer
But If I remove the application bundle id from iOS Apps then API key is working
Also I'm referring this question This IP, site or mobile application is not authorized to use this API key
But some confusion are, Can we keep it as blank? There is any security related issue? do I need to do any changes when I'm going to upload app on app store ?
NOTE: I'm using API key in all the places in the coding. like
GMSServices.provideAPIKey(googleAPIKey)
and
let urlString = "https://maps.googleapis.com/maps/api/directions/json?origin=\(myCoordinateStr)&destination=\(destinationCoorinateStr)&key=\(googleAPIKey)&sensor=true"

Custom scheme URIs are not allowed for 'Web' client type - Google with Firebase

I am trying to implement google sign in using firebase in to my iOS app. I follow this tutorial.
https://firebase.google.com/docs/auth/ios/google-signin
I have setup the iOS app in firebase and use the google clientID and reversedClientID from the dowloaded GoogleService-Info.plist.
FYI: I have a custom sign-in button instead of the google sign in button. Anyway when i click the sign in button, google following error display in a webview.
I know my problem is the same as which described in this question.
Google 400 Error: invalid request Custom scheme URIs are not allowed for 'Web' client type
But, in my case, I have created the app in Firebase still I get the error. Any idea please...
The first step is to check if you have already the OAuth 2.0 ID for iOS. To do this please open the Credentials page in the API Console. I hope you will find iOS client for your application under OAuth 2.0 client IDs section. If not, please follow this Guide
The second step is to replace the Web Client ID with in iOS Client ID from OAuth 2.0 client IDs section. To do this, you should open the GoogleService-Info.plist and modify following keys: CLIENT_ID with [value].apps.googleusercontent.com and REVERSED_CLIENT_ID with com.googleusercontent.apps.[value].
if you're using flutterfire ui package you need to change the client id parameter in your GoogleProviderConfiguration class with the iOS client id,
you can copy it from here Credential page
example:
providerConfigs: [
GoogleProviderConfiguration(
clientId: "your copied key here"),
]
re-build you're app and you should be good to go
I've just faced this same issue using flutterfire_ui on Flutter.
The error appears to be from a couple of things. As Valeriy points out you need the ios client ID. But I still got the error if I used the scopes
openid
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
Instead change these to
openid
email
profile
Strangely the opposite is true for Android, where the WebID and the first of the scopes should be used.
It also pays to be aware of the OAuth Content Screen..
In google cloud go to APIs & Services > OAuth consent screen > Edit.
You can add scopes here and fix any missing required fields that Firebase might not be filling out (I had 1). I believe this takes a while to propagate after a change, so give it an hour.

How to get client secret from Google Developers Console in iOS?

Currently i am working on one of old project within that there is a client id and client secret. Now i want to update those with new client id and client secret using another Developer account. I followed each and every step from
https://developers.google.com/+/mobile/ios/getting-started
Google APIs Console - missing client secret
But i can see only client id. Where is the client secret ?
Here i can see only client id
Hey this is step by step process ,hope this helps you...
Step 1:
Goto Google Developer console and create new app
Step 2:Enable the google plus api
You can see the enable api in the Enable API's tab which is next to API Library ,which is visible in second image.
Step 3: Goto to credential in API & auth tab then select credentials option
select the type of authentication you require
then you will can see the configure consent screen configure the page with the information you wish to provide .
Step 4: Select the web Application option on top
and enter required url's
and finally click create button
once you do that ..you can see ...client id and client secret key...
When in iOS, the application type of the OAuth credential should be 'iOS'.
And then you should pass an empty string as the client secret in your code.
Keeping a secret (that is global to the entire application, not unique per user) in an app is NEVER EVER secure. See https://developer.okta.com/blog/2019/01/22/oauth-api-keys-arent-safe-in-mobile-apps This is an amazing article, please spend as much time as needed to understand it.
Because it can't be kept secure, using client secret in iOS is the old, outdated approach. Nowadays you want to use proof-key-code-exchange (PKCE). It's also explained in above link, but in short:
Generate a secret key in iOS, it is one time use for that one specific login
Only send the hash of the key to the login authority (Google). The original has not left the app yet
To get the tokens, you send: <AuthorizationCode,ORIGINAL secret> AuthorizationCode is also a one time use
Google can compare the "original secret" to the previously sent hash. It therefore knows you are not an attacker that has stolen the AuthorizationCode
Back to the question. Google let's you create different types of "Apps":
Web application: Has a client secret (It's on a backend server, not on a publicly accessible iOS app)
iOS app: Has "iOS URL scheme" instead. There are frameworks that use this URL scheme and do the steps I described above for you (including PKCE). Disclaimer: I'm not an iOS developer, but I'm 99% certain

Update thumbnail without asking for google login - Youtube API V3.0 - OAuth2.0 -

My goal is quite simple : Use php files that will log on my youtube account and upload custom thumbnails.
I already successfully used Youtube API V2 to upload videos with no problem,
but the V3 requires OAuth2.0, and I can't found a way to avoid my server keeps ask me "Please login from your google account"
I use the example from the official place, here :
And created my OAuth token (tried web application and service) but it keeps ask me to log in...
I only want the php files to log on alone, because I want to share them to some friends that will be able to change thumbnails without having a google acount or knowing my youtube/google password.
You can do so by getting a refresh token from OAuth2 Playground and setting it in your youtube object.
Here it explains a little more.
And a step by step video.
Thank you Ibrahim, it solved my problem :) !
Except you didn't mentionned that I had to use $client->refreshToken('Refresh Token'); and then start the conditional : if ($client->getAccessToken()) { [...] . Very important to the others one who could encounter the problem : You need to use google developper console https://cloud.google.com/console and specify in APIs & Ath > Credentials the exact adress of your PHP script, and set a product name and email address in Consent Screen.

Facebook Connect for BlackBerry

I'm looking for a solution similar to the iPhone Facebook Connect (https://github.com/facebook/facebook-ios-sdk) for the BlackBerry platform. Basically, I need my users to authenticate against Facebook from within a native BlackBerry application (so, not a Web based mobile application). Is there a library I could use, and if not, what will be the correct approach to achieve this?
Thanks in advance!
Options for BlackBerry are:
Use Facebook Platform for Mobile
Use REST API approach provided by Eki Y. Baskoro
Try to port JavaFB from J2SE to J2ME
I managed to go through Facebook Connect authentication within my BB app. After cracking my head for three days I realised that it is the URL that is the culprit!
Basically these are what you need (assuming you are developing for 4.5 platform):
Using Browser Field, do a POST to http://m.facebook.com/login.php (the mobile version of Facebook) passing all the necessary arguments as per the Desktop application counterparts (one challenge is to get the signature generation correct).
Once the User successfully grants access, capture the URL of the success screen. You will obtain your auth_token.
Do a POST to the REST server to obtain the session key and secret given the auth_token you obtain.
Save the returned session key and secret, persist it, and wholla! your app is up and running.
I am developing a custom LoginScreen and FacebookFacade object to incorporate the first three steps above, if anyone is ever interested to reuse my code. It'll be GPLed, I suppose ;)
Afzal, I had a similar problem and I've found out that I actually had a problem with my connection string. You can look at the following link there is some explanation and code for creating the correct connection string
http://www.localytics.com/blog/post/how-to-reliably-establish-a-network-connection-on-any-blackberry-device/
and just add the connection string to the FetchThread where it opens the connection:
connection = (HttpConnection)Connector.open(absoluteUrl+getConnectionString());

Resources