File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
analyticsdata/quickstart_oauth2 Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ Choose "Web application" when asked for an application type.
14
14
https://support.google.com/cloud/answer/6158849
15
15
16
16
2 . When configuring the web application credentials, add
17
- "http://localhost:3000 " to "Authorized redirect URIs".
17
+ "http://localhost:3000/ " to "Authorized redirect URIs".
18
18
19
19
3 . Download a credentials file using "Download JSON" button in the credentials
20
20
configuration dialog and save it as ` oauth2.keys.json ` in the same
@@ -38,4 +38,4 @@ php -S localhost:3000 -t .
38
38
```
39
39
7 . In a browser, open the following url to start the sample:
40
40
41
- https ://localhost:3000/
41
+ http ://localhost:3000/
Original file line number Diff line number Diff line change 50
50
if (isset ($ _SESSION ['access_token ' ]) && $ _SESSION ['access_token ' ]) {
51
51
// This is the final step of the OAuth2 authorization process, where an
52
52
// OAuth2 access token is available and can be used to set up a client.
53
- $ oauth ->updateToken (['refresh_token ' => $ _SESSION ['access_token ' ]]);
53
+ $ oauth ->setAccessToken ($ _SESSION ['access_token ' ]);
54
+ $ oauth ->setRefreshToken ($ _SESSION ['refresh_token ' ]);
54
55
55
56
// Make an API call.
56
57
$ client = new AlphaAnalyticsDataClient (['credentials ' => $ oauth ]);
98
99
// Persist the acquired access token in a session.
99
100
$ _SESSION ['access_token ' ] = $ oauth ->getAccessToken ();
100
101
102
+ // Persist the acquired refresh token in a session.
103
+ $ _SESSION ['refresh_token ' ] = $ oauth ->getRefreshToken ();
104
+
101
105
// Refresh the current page.
102
106
$ redirect_uri = 'http:// ' . $ _SERVER ['HTTP_HOST ' ] . '/ ' ;
103
107
header ('Location: ' . filter_var ($ redirect_uri , FILTER_SANITIZE_URL ));
You can’t perform that action at this time.
0 commit comments