API Hello Analytics: inicio rápido en PHP para aplicaciones web API de administración de Analytics


To do this, include the access token in a request to the API by including either an access_token query parameter or an Authorization HTTP header Bearer value. When possible, the HTTP header is preferable, because query strings tend to be visible in server logs. In most cases you can use a client library to set up your calls to Google APIs . If the user grants access to your application, you can exchange the authorization code for an access token and a refresh token as described in the next step. Redirect_uri Required Determines how Google’s authorization server sends a response to your app.

Since your redirect_uri can be guessed, using a statevalue can increase your assurance that an incoming connection is the result of an authentication request. See the OpenID Connectdocumentation for an example of how to create and confirm a state token. Code_challenge_method Recommended Specifies what method was used to encode a code_verifier that will be used during authorization code exchange. This parameter must be used with the code_challenge parameter described above. The value of the code_challenge_methoddefaults to plain if not present in the request that includes a code_challenge.

The OAuth client ID in the request is part of a project limiting access to Google Accounts in a specific Google Cloud Organization. For more information about this configuration option see the User typesection in the Setting up your OAuth consent screen help article. Login_hint Optional If your application knows which user is trying to authenticate, it can use this parameter to provide a hint to the Google Authentication Server. The server uses the hint to simplify the login flow either by prefilling the email field in the sign-in form or by selecting the appropriate multi-login session. Set the parameter value to code for installed applications. Com.googleusercontent.apps.123 is the reverse DNS notation of the client ID.

The value is most commonly displayed in the General pane or the Signing & Capabilities pane of the Xcode project editor. The bundle ID is also displayed in the General Information section of the App Information page for the app on Apple’s App Store Connect site. Use the Library page to find and enable the YouTube Data API. Find any other APIs that your application will use and enable those, too. Any application that calls Google APIs needs to enable those APIs in the API Console. // from the client_secrets.json you downloaded from the Developers Console.

Review authorized redirect URIs in the Google API Console Credentials page. IOS and macOS developers may encounter this error when opening authorization requests in WKWebView. Developers should instead use iOS libraries such as Google Sign-In for iOS or OpenID Foundation’s AppAuth for iOS. Your application doesn’t need to do anything at this stage as it waits for the response from Google’s OAuth 2.0 server indicating whether any access was granted. The following steps show how your application interacts with Google’s OAuth 2.0 server to obtain a user’s consent to perform an API request on the user’s behalf. Your application must have that consent before it can execute a Google API request that requires user authorization.

Requests to Google’s OAuth 2.0 authorization endpoint may display user-facing error messages instead of the expected authentication and authorization flows. Common error codes and suggested resolutions are listed below. Scope Required A space-delimited list of scopes that identify the resources that your application could access on the user’s behalf. These values inform the consent screen that Google displays to the user. Response_type Required Determines whether the Google OAuth 2.0 endpoint returns an authorization code.

Note that support for the loopback IP address redirect option on mobile apps is DEPRECATED. Plain The code challenge is the same value as the code verifier generated above. Code Challenge Generation Methods S256 The code challenge is the Base64URL encoded SHA256 hash of the code verifier. Before you start implementing OAuth 2.0 authorization, we recommend that you identify the scopes that your app will need permission to access.

When your app receives the authorization response, for best usability it should respond by displaying an HTML page that instructs the user to close the browser and return to your app. A custom URI scheme is recommended for Android apps, iOS apps, and Universal Windows Platform apps. Installed apps are distributed to individual devices, and it is assumed that these apps cannot keep secrets. They can access Google APIs while the user is present at the app or when the app is running in the background. // else redirect to ask the user to authorize access to Google Analytics.

// from the client_secretes.json you downloaded from the developer console. The code verifier should have enough entropy to make it impractical rutgers expository writing to guess the value. The bundle ID is the value of the CFBundleIdentifierkey in your app’s information property list resource file (info.plist).