GooglePlayInstant/Editor/QuickDeploy/AccessTokenGetter.cs
/// <summary>
/// Instantiates the OAuth2 flow to retrieve authorization code for google cloud storage, and schedules
/// invocation of the code handler on the received authorization code once it is available. Throws an exception
/// once there is a failure to get the authorization code from the oauth2 flow.
/// </summary>
/// <param name="onAuthorizationCodeAction">An action to invoke on the authorization code instance when it is
/// available.</param>
Instantiates the OAuth2 flow to retrieve authorization code for google cloud storage, and schedules
invocation of the code handler on the received authorization code once it is available. Throws an exception
once there is a failure to get the authorization code from the oauth2 flow.
Instantiates the OAuth2 flow to retrieve authorization code for google cloud storage and schedules invocation of the code handler on the received authorization code once it is available . Throws an exception once there is a failure to get the authorization code from the oauth2 flow .
private static void GetAuthCode(Action<AuthorizationCode> onAuthorizationCodeAction)
        {
            var server = new OAuth2Server(authorizationResponse => { _authorizationResponse = authorizationResponse; });
            server.Start();
            var redirectUri = server.CallbackEndpoint;
            _onOAuthResponseReceived = authorizationResponse =>
            {
                if (!string.Equals("code", authorizationResponse.Key))
                {
                    throw new Exception("Could not receive required permissions");
                }
                var authCode = new AuthorizationCode
                {
                    Code = authorizationResponse.Value,
                    RedirectUri = redirectUri
                };
                if (onAuthorizationCodeAction != null)
                {
                    onAuthorizationCodeAction(authCode);
                }
            };
            var credentials = OAuth2Credentials.GetCredentials();
            var authorizationUrl =
                string.Format("{0}?scope={1}&access_type=offline&redirect_uri={2}&response_type=code&client_id={3}",
                    credentials.auth_uri, CloudStorageFullControlScope, redirectUri, credentials.client_id);
            Application.OpenURL(authorizationUrl);
        }
private static void GetAuthCode ( Action < AuthorizationCode > onAuthorizationCodeAction ) { var server = new OAuth2Server ( authorizationResponse => { _authorizationResponse = authorizationResponse ; } ) ; server . Start ( ) ; var redirectUri = server . CallbackEndpoint ; _onOAuthResponseReceived = authorizationResponse => { if ( ! string . Equals ( " " , authorizationResponse . Key ) ) { throw new Exception ( " " ) ; } var authCode = new AuthorizationCode { Code = authorizationResponse . Value , RedirectUri = redirectUri } ; if ( onAuthorizationCodeAction != null ) { onAuthorizationCodeAction ( authCode ) ; } } ; var credentials = OAuth2Credentials . GetCredentials ( ) ; var authorizationUrl = string . Format ( " " , credentials . auth_uri , CloudStorageFullControlScope , redirectUri , credentials . client_id ) ; Application . OpenURL ( authorizationUrl ) ; }
Instantiates the OAuth2 flow to retrieve authorization code for google cloud storage, and schedules
invocation of the code handler on the received authorization code once it is available.
Instantiates the OAuth2 flow to retrieve authorization code for google cloud storage and schedules invocation of the code handler on the received authorization code once it is available .
// Take the user to the authorization page to authorize the application.
onAuthorizationCodeAction
Action<AuthorizationCode>
An action to invoke on the authorization code instance when it is
available.
An action to invoke on the authorization code instance when it is available .