Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Search Console API O-Auth from Settings #80

Open
franzenzenhofer opened this issue Feb 28, 2019 · 16 comments
Open

Google Search Console API O-Auth from Settings #80

franzenzenhofer opened this issue Feb 28, 2019 · 16 comments
Assignees

Comments

@franzenzenhofer
Copy link
Owner

it should be possible to access the

Google Search Console API (https://developers.google.com/apis-explorer/#p/webmasters/v3/ )
Google Analytics API (https://developers.google.com/analytics/devguides/reporting/core/v4/ )

from the rules

for this we need an OAuth 2 Token
GSC: https://developers.google.com/webmaster-tools/search-console-api-original/v3/how-tos/authorizing
GA: https://developers.google.com/analytics/devguides/reporting/core/v4/authorization
(read only access it enough)

on the "Settings" Section it should be able to start the authentiaction. the OAuth Verification Section should before the rules.

in the context of the rules the oauth token shoud be available as someting like

context.tokens.google_search_console
context.tokens.google_analytics


please implement some sample rules that show the access to these APIs


(in the application the code should be implmented in a way that it is relatively easy to add other oauth verifcation pathns in the future )


@franzenzenhofer
Copy link
Owner Author

hi, ja, wäre super, hiermit beauftragt, ruf mich an falls fragen gibt.

idee ist dass ich mich via oauth2.0. in den settings bei google search console, google analytics anmelden kann.

dann zugriff auf den oauth token von den regeln aus (globals)

dann regeln schreiben die die den oauth token verwenden können . bitte auch eine dummy regel schreiben als proove of concept.

@neuling
Copy link
Collaborator

neuling commented Mar 14, 2019

Erste Implementierung sollte funktionieren inkl. Beispiel-Rule (https://github.com/franzenzenhofer/f19n-obtrusive-livetest/blob/master/src/public/default-rules/google-api-token.js).

Es ist allerdings so, dass wir in der App (Google Console) die Extension-ID angeben müssen. Ich muss noch checken, ob sich diese ID eh nicht ändert und wenn doch, müssten wir die ID fixieren. Ich gebe dir diesbezüglich noch bescheid was von deiner Seite dann zu tun wäre.

Sofern bei dir die Extension-ID im development modus folgende ist jhpgmhnbhbbicghjgdipjoodolgclkek kannst du die aktuelle Implementierung schon mal testen. Wenn nicht, gib bescheid.

Screenshot 2019-03-14 22 33 31

Screenshot 2019-03-14 22 33 46

Screenshot 2019-03-14 22 34 10

Screenshot 2019-03-14 22 34 23

@franzenzenhofer
Copy link
Owner Author

hi

meine ID is leider
image

bei 'nen click mit "sign in with google" bekomme ich

image

i found this online
https://developer.chrome.com/apps/manifest/key

@neuling
Copy link
Collaborator

neuling commented Mar 15, 2019

@franzenzenhofer Hab jetzt einen fixen public key im manifest gesetzt. Sollte zur folge haben, dass die Extension beim Entwickeln immer die selbe ID bekommt (njakpgmhmabjndneefpeehijmkepmkmd).

Habe die ID auch entsprechend bei der App eingetragen.

Außerdem habe ich zwecks sauberer Trennung eine eigene App für Development (DEV) angelegt.

@franzenzenhofer
Copy link
Owner Author

frage: funkt das dann auch in der fertigen gebuildeten app nach den rollout via appstore?

@franzenzenhofer
Copy link
Owner Author

Außerdem habe ich zwecks sauberer Trennung eine eigene App für Development (DEV) angelegt.
? bitte um mehr context, wo?

@franzenzenhofer
Copy link
Owner Author

Oauth Works now.

If it's successfully conneceted please add a checkmark next to the headline:

Connect with Google ✅

@franzenzenhofer
Copy link
Owner Author

will write first rule today at night for further testing

@franzenzenhofer
Copy link
Owner Author

franzenzenhofer commented Mar 18, 2019

hi @neuling

i'm struggling to make the API requests work

with this rule
https://github.com/franzenzenhofer/f19n-obtrusive-livetest/blob/610ba67c518194ca8ae01d1d716860d67004d4b7/src/public/default-rules/google-search-console-webproperty-available.js

i get this console output (background.html)
image

this is the same error response as if i do not give an KEY value

test case
when visiting this page
https://www.fullstackoptimization.com/

i gave you access to this domain in google search console to your email ([email protected]) so you can test

@neuling
Copy link
Collaborator

neuling commented Mar 18, 2019

@franzenzenhofer I just figured out you need to send the access_token via Authorization header instead of key URL param. I changed the rule and from what i can see the rules works now.

neuling added a commit that referenced this issue Mar 18, 2019
@franzenzenhofer
Copy link
Owner Author

hi, it works great until it doesn't.

i often get an http 401 - invalid token.

then i need to disconnect - connect again and it works great again.

here are some hints why this happens
https://stackoverflow.com/questions/17813621/oauth2-0-token-strange-behaviour-invalid-credentials-401

i also can confirm it happens when i change network (and with this prop my ip and with this the token is imvalidl

is there a way to prevent this token invalidation - or - to automate the connect/disconnect dance? either on an event, regularly or a method / message i can ise from the rules?

@neuling
Copy link
Collaborator

neuling commented Mar 25, 2019

Got it. Will find a solution for this problem.

@franzenzenhofer
Copy link
Owner Author

hi moritz, would be awesome if we could finish this in the near future so we can focus on that other project

@franzenzenhofer
Copy link
Owner Author

ping @neuling

@neuling
Copy link
Collaborator

neuling commented Apr 8, 2019

Sorry, I am on it … update soon.

@neuling
Copy link
Collaborator

neuling commented Apr 8, 2019

@franzenzenhofer Pls pull and test it again. I will check for a fresh accessToken before the rules get executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants