Where to place Google API keys in CEF3 binary

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Where to place Google API keys in CEF3 binary

Postby HappyCoder13 » Wed Jan 08, 2014 2:37 am

Hi friends,

I need your help.

I am working on developing an application where users among other things, be able to submit their GPS coordinates. So geolocation. I therefore look CEF as the solution.
I have downloaded "Current CEF3 binary release" (for Windows) from magpcss.net
I created the "Client ID for native application" and "Key for browser applications" - both in Google Developers Cloud . I have even enabled a large number of APIs (also for many) . I have enabled the following services:
Chrome Remote Dekstop API
Chrome Spelling API
Chrome Suggest API
Chrome Sync API
Chrome Translate Element
Google Cloud Messaging for Chrome
Google Maps API v3
Google Maps Coordinate API
Google Maps Engine API
Google Maps Geolocation API
Goolge Maps Tracks API
Safe Browsing API
Speech API

I have also enabled billing for my application.

Back to the problem. I have downloaded "Current CEF3 binary release" (for Windows), and need to help where in the code I need to insert my Google API keys . Can you help me with that?

I hope you understand (despite my english)
HappyCoder13
Newbie
 
Posts: 8
Joined: Fri Dec 27, 2013 7:41 am

Re: Where to place Google API keys in CEF3 binary

Postby magreenblatt » Wed Jan 08, 2014 11:14 am

You need to set environment variables as described at http://www.chromium.org/developers/how-tos/api-keys. You can set them in a script before launching the executable or programatically using OS functions before calling CefInitialize.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Where to place Google API keys in CEF3 binary

Postby HappyCoder13 » Wed Jan 08, 2014 11:21 am

Hello magreenblatt,

Thanks for your response!

I have already tried to follow the wizard to make include.gypi - but unfortunately without success.
Can you help with an example to how I put them in the script?
HappyCoder13
Newbie
 
Posts: 8
Joined: Fri Dec 27, 2013 7:41 am

Re: Where to place Google API keys in CEF3 binary

Postby magreenblatt » Wed Jan 08, 2014 11:52 am

Sure, a script might look like this on Linux:
Code: Select all
#!/bin/sh
export GOOGLE_API_KEY=xxxxx
export GOOGLE_DEFAULT_CLIENT_ID=xxxxx
export GOOGLE_DEFAULT_CLIENT_SECRET=xxxxx
./my-executable


If you change include.gypi then you need to rebuild CEF/Chromium as described on the BranchesAndBuilding wiki page.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Where to place Google API keys in CEF3 binary

Postby HappyCoder13 » Sat Jan 11, 2014 5:51 pm

I must do something wrong.
I installed a clean Windows and followed your guide step by step. When I finish the wizard, I have ...\chromium\src\cef\binary_distrib\cef_binary_3.1650.1560_windows32\ and I open cefclient2010.sln and adds "callback" to OnRequestGeolocationPermission so it looks like this:

Code: Select all
 virtual void OnRequestGeolocationPermission (
      CefRefPtr <CefBrowser> browser
      const CefString & requesting_url ,
      int request_id ,
      CefRefPtr <CefGeolocationCallback> callback ) {
callback->Continue(true);
  }


In Visual Studio C++ Express I build the solution. And then I go to ...\chromium\src\cef\binary_distrib\cef_binary_3.1650.1560_windows32\out\Debug and running cefclient.exe
Now I get the error:
ERROR (2): Network location provider at https://www.googleapis.com : Returned error code 403

I of course assured me include.gypi file in C:\Users\myUsername\.gyp before I build CEF/Chromium, as you described.

What am I doing wrong?
HappyCoder13
Newbie
 
Posts: 8
Joined: Fri Dec 27, 2013 7:41 am

Re: Where to place Google API keys in CEF3 binary

Postby magreenblatt » Sat Jan 11, 2014 7:38 pm

You can't use include.gypi with the binary distribution. It only works when you build CEF/Chromium from source code as described in the BranchesAndBuilding wiki page.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Where to place Google API keys in CEF3 binary

Postby HappyCoder13 » Mon Jan 13, 2014 2:29 pm

I am again on a fresh start. I have set up development environment in the guide. I also made include.gypi only with my Google APIs. Then I have do..
Code: Select all
gclient config http://src.chromium.org/svn/releases/31.0.1650.57

And then
Code: Select all
svn co http://chromiumembedded.googlecode.com/svn/branches/1650/cef3 cef

I have run cef_create_projects.bat and added callback->Continue(true); in OnRequestGeolocationPermission.
I have built the project using
Code: Select all
build_projects.bat Debug


When build_projects is finished (after a long time :)), the cefsimple.exe is in the folder ..\chromium\src\build\Debug and when I execute the file, I still get the same error 403 / location service is unavailable.

Can you help me on the way to the right solution?
HappyCoder13
Newbie
 
Posts: 8
Joined: Fri Dec 27, 2013 7:41 am

Re: Where to place Google API keys in CEF3 binary

Postby magreenblatt » Mon Jan 13, 2014 2:37 pm

Did you create the include.gypi file as described here: http://www.chromium.org/developers/how-tos/api-keys ?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Where to place Google API keys in CEF3 binary

Postby HappyCoder13 » Mon Jan 13, 2014 2:52 pm

Yes, the file content is (copy/paste):
Code: Select all
{
  'variables': {
   'google_api_key':               'xxx',
   'google_default_client_id':     'yyy,
   'google_default_client_secret': 'zzz'
  }
}


When I generated the build files it says: Using overrides found in C:\Users\myUsername\.gyp\include.gypi
HappyCoder13
Newbie
 
Posts: 8
Joined: Fri Dec 27, 2013 7:41 am

Re: Where to place Google API keys in CEF3 binary

Postby magreenblatt » Mon Jan 13, 2014 3:42 pm

HappyCoder13 wrote:When I generated the build files it says: Using overrides found in C:\Users\myUsername\.gyp\include.gypi

OK, then it should be using your keys. I'm not sure why you're seeing 403 errors. You might need to post on the chromium-dev mailing list about it.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 239 guests