So thanks to @salvadordf and
https://github.com/googlesamples/oauth- ... r-windows/ (C#), I managed to get OAuth2 credentials with C++/CEF/OpenFrameworks/Visual Studio/Windows 10.
See attached rather rough and ready code which could easily be adapted to any windows cef app.
I haven't yet tried exchanging the refresh token but it should be straightforward now.
Instead, I've tried using the access token with a browser but like @salvadordf I'm unable to make it work.
Here's how I tried:
- Code: Select all
void MyBrowser::authload(string url, string token) {
CefRefPtr<CefFrame> frame = browser_->GetMainFrame();
CefRefPtr<CefRequest> request = CefRequest::Create();
request->SetMethod("GET");
request->SetURL(url);
CefRequest::HeaderMap headerMap;
headerMap.insert(std::make_pair("Authorization", "Bearer%20" + token));
request->SetHeaderMap(headerMap);
frame->LoadRequest(request);
}
Using a url which is a shareable link to a presentation on my company's google drive and an access token resulting from an OAuth2 login to my company account I still get asked for user and password.
I've tried several different variants and nothing works.
After a lot of research I'm coming to the conclusion that I can only use the token with direct requests to google API's .
Am I right, or can anyone suggest another way?
I guess that using the google drive API I could download the presentation and open it locally with a CEF browser but I haven't tried going down that rabbit hole yet.
Particularly as to make it work in the real world we would have to submit my app to google for review at a cost of at least $15000 and I have a feeling they may reject this usage.
See
https://support.google.com/cloud/answer/9110914