Class FOSAccountCredential
java.lang.Object
com.amazon.A3L.authentication.api.client.extensions.fos.auth.FOSAccountCredential
- All Implemented Interfaces:
com.google.api.client.http.HttpRequestInitializer
,com.google.api.client.http.HttpUnsuccessfulResponseHandler
public class FOSAccountCredential
extends Object
implements com.google.api.client.http.HttpRequestInitializer, com.google.api.client.http.HttpUnsuccessfulResponseHandler
FOSAccountCredential class uses a credential to provide access to Google API Client libraries
-
Constructor Summary
ConstructorsConstructorDescriptionFOSAccountCredential
(Context context, String scope) Default constructor for FOSAccountCredential. -
Method Summary
Modifier and TypeMethodDescriptionfinal Account[]
Method to return the current account which is signed incom.google.api.client.util.BackOff
Method for getting the BackOff value.final Context
Getter for contextfinal String
getScope()
Getter for scopefinal Account
Method to return the current account which is signed infinal String
It returns the account name if the selected account name was the same as signed in accountfinal com.google.api.client.util.Sleeper
Getter for Sleeper.getToken()
method to get the current access_tokenboolean
handleResponse
(com.google.api.client.http.HttpRequest request, com.google.api.client.http.HttpResponse response, boolean supportsRetry) Handler method which is invoked in case of unsuccessful response.void
initialize
(com.google.api.client.http.HttpRequest request) Initializes a http request prior to executionsetBackOff
(com.google.api.client.util.BackOff backOff) Method for setting the BackOff value.setSelectedAccount
(Account account) Method to set the current account, it checks if the account passed is the same as the signed in accountsetSelectedAccountName
(String accountName) Method to set the selected account name, it checks if the account name is same as the signed in account namefinal FOSAccountCredential
setSleeper
(com.google.api.client.util.Sleeper sleeper) Method for setting sleeper value.static FOSAccountCredential
usingOAuth2
(Context context, Collection<String> scopes) Static method which can be used to create an instance of new FOSAccountCredential
-
Constructor Details
-
FOSAccountCredential
Default constructor for FOSAccountCredential.- Parameters:
context
- - A Context * used to provide information about the application's environment.scope
- - the scope for the
-
-
Method Details
-
usingOAuth2
Static method which can be used to create an instance of new FOSAccountCredential- Parameters:
context
- : A Context * * used to provide information about the application's environment.scopes
- : Collectionof OAuth 2.0 scope list which are authorized during sign-in - Returns:
- FOSAccountCredential
-
setSelectedAccount
Method to set the current account, it checks if the account passed is the same as the signed in account- Parameters:
account
- : Account which is signed in.- Returns:
- FOSAccountCredential
-
setSelectedAccountName
Method to set the selected account name, it checks if the account name is same as the signed in account name- Parameters:
accountName
- : name of the account which is signed in- Returns:
- FOSAccountCredential
-
getContext
public final Context getContext()Getter for context- Returns:
- Context
-
getScope
Getter for scope- Returns:
- String - containing list of all the provided OAuth 2.0 scopes which are part of granted scopes
-
getAllAccounts
public final Account[] getAllAccounts()Method to return the current account which is signed in- Returns:
- Account[] - a list containing only the current signed in account
-
getSelectedAccount
public final Account getSelectedAccount()Method to return the current account which is signed in- Returns:
- Account - the current signed in account
-
getBackOff
public com.google.api.client.util.BackOff getBackOff()Method for getting the BackOff value. It is a no-op method.- Returns:
- BackOff
-
setBackOff
Method for setting the BackOff value. It is a no-op method.- Parameters:
backOff
-- Returns:
- FOSAccountCredential
-
getSleeper
public final com.google.api.client.util.Sleeper getSleeper()Getter for Sleeper. It is a no-op method.- Returns:
- Sleeper
-
setSleeper
Method for setting sleeper value. It is a no-op method.- Parameters:
sleeper
-- Returns:
- FOSAccountCredential
-
getSelectedAccountName
It returns the account name if the selected account name was the same as signed in account- Returns:
- String - the account name
-
getToken
method to get the current access_token- Returns:
- String
-
initialize
Initializes a http request prior to execution- Specified by:
initialize
in interfacecom.google.api.client.http.HttpRequestInitializer
- Parameters:
request
- : HTTP request- Throws:
IOException
-
handleResponse
public boolean handleResponse(com.google.api.client.http.HttpRequest request, com.google.api.client.http.HttpResponse response, boolean supportsRetry) Handler method which is invoked in case of unsuccessful response.- Specified by:
handleResponse
in interfacecom.google.api.client.http.HttpUnsuccessfulResponseHandler
- Parameters:
request
- : Request object that can be read from for context or modified before retryresponse
- : Response to processsupportsRetry
- : Boolean- Returns:
- Boolean
-