本文整理汇总了Java中com.amazon.identity.auth.device.authorization.api.AmazonAuthorizationManager类的典型用法代码示例。如果您正苦于以下问题:Java AmazonAuthorizationManager类的具体用法?Java AmazonAuthorizationManager怎么用?Java AmazonAuthorizationManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AmazonAuthorizationManager类属于com.amazon.identity.auth.device.authorization.api包,在下文中一共展示了AmazonAuthorizationManager类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getAccessToken
import com.amazon.identity.auth.device.authorization.api.AmazonAuthorizationManager; //导入依赖的package包/类
/**
* Check if we have a pre-existing access token, and whether that token is expired. If it is not, return that token, otherwise get a refresh token and then
* use that to get a new token.
* @param authorizationManager our AuthManager
* @param context local/application context
* @param callback the TokenCallback where we return our tokens when successful
*/
public static void getAccessToken(@NotNull AmazonAuthorizationManager authorizationManager, @NotNull Context context, @NotNull TokenCallback callback) {
SharedPreferences preferences = Util.getPreferences(context.getApplicationContext());
//if we have an access token
if(preferences.contains(PREF_ACCESS_TOKEN)){
if(preferences.getLong(PREF_TOKEN_EXPIRES, 0) > System.currentTimeMillis()){
//if it's not expired, return the existing token
callback.onSuccess(preferences.getString(PREF_ACCESS_TOKEN, null));
return;
}else{
//if it is expired but we have a refresh token, get a new token
if(preferences.contains(PREF_REFRESH_TOKEN)){
getRefreshToken(authorizationManager, context, callback, preferences.getString(PREF_REFRESH_TOKEN, ""));
return;
}
}
}
//uh oh, the user isn't logged in, we have an IllegalStateException going on!
callback.onFailure(new IllegalStateException("User is not logged in and no refresh token found."));
}
开发者ID:vaibhavs4424,项目名称:AI-Powered-Intelligent-Banking-Platform,代码行数:29,代码来源:TokenManager.java
示例2: AuthorizationManager
import com.amazon.identity.auth.device.authorization.api.AmazonAuthorizationManager; //导入依赖的package包/类
/**
* Create a new Auth Manager based on the supplied product id
*
* This will throw an error if our assets/api_key.txt file, our package name, and our signing key don't match the product ID, this is
* a common sticking point for the application not working
* @param context
* @param productId
*/
public AuthorizationManager(@NotNull Context context, @NotNull String productId){
mContext = context;
mProductId = productId;
try {
mAuthManager = new AmazonAuthorizationManager(mContext, Bundle.EMPTY);
}catch(IllegalArgumentException e){
//This error will be thrown if the main project doesn't have the assets/api_key.txt file in it--this contains the security credentials from Amazon
Util.showAuthToast(mContext, "APIKey is incorrect or does not exist.");
Log.e(TAG, "Unable to Use Amazon Authorization Manager. APIKey is incorrect or does not exist. Does assets/api_key.txt exist in the main application?", e);
}
}
开发者ID:vaibhavs4424,项目名称:AI-Powered-Intelligent-Banking-Platform,代码行数:21,代码来源:AuthorizationManager.java
示例3: logoutAndUnlink
import com.amazon.identity.auth.device.authorization.api.AmazonAuthorizationManager; //导入依赖的package包/类
private void logoutAndUnlink() {
// logout/unlink and wipe local dataset
// new CognitoUnlinkTask().execute();
Session session = Session
.openActiveSessionFromCache(SnakeGameActivity.this);
if (session != null) {
session.closeAndClearTokenInformation();
}
// if (googleApiClient != null) {
// googleApiClient.clearDefaultAccount();
// }
AmazonAuthorizationManager mAuthManager = new AmazonAuthorizationManager(
this, Bundle.EMPTY);
if (mAuthManager != null) {
mAuthManager.clearAuthorizationState(null);
}
AWSClientManager.getCognitoSync().wipeData();
Toast.makeText(gameView.getContext(), "Logout Successful",
Toast.LENGTH_SHORT).show();
}
开发者ID:jinman,项目名称:snake-game-aws,代码行数:28,代码来源:SnakeGameActivity.java
示例4: initData
import com.amazon.identity.auth.device.authorization.api.AmazonAuthorizationManager; //导入依赖的package包/类
private void initData() {
hasSentEvents = false;
hasGotProfile = false;
hasGotToken = false;
/*
* Initializes CognitoSyncClientManager and DynamoDBManager,
* initialization must be called before you can use them.
*/
CognitoSyncClientManager.init(this);
DynamoDBManager.init();
mNumberOfGuesses = getIntent().getIntExtra(
GuessActivity.TIMES_OF_GUESSES, 0);
mSecondsUsed = getIntent().getIntExtra(GuessActivity.TIME_TO_COMPLETE,
0);
mBestScore = getIntent().getIntExtra(GuessActivity.BEST_SCORE, 0);
mCurrentScore = calculateScore(mNumberOfGuesses, mSecondsUsed);
Log.i(TAG, "Best score = " + mBestScore + ", Current score = "
+ mCurrentScore);
if (mCurrentScore > mBestScore) {
mBestScore = mCurrentScore;
new InsertRecordTask().execute();
}
/*
* Initializes MobileAnalyticsClientManager, it must be called before
* you can use it.
*/
MobileAnalyticsClientManager.init(ResultActivity.this);
try {
mAuthManager = new AmazonAuthorizationManager(this, Bundle.EMPTY);
} catch (IllegalArgumentException e) {
Toast.makeText(this, "Login with Amazon is disabled.",
Toast.LENGTH_LONG).show();
Log.w(TAG, "Login with Amazon isn't configured correctly. "
+ "Thus it's disabled in this demo.", e);
}
}
开发者ID:awslabs,项目名称:aws-sdk-android-samples,代码行数:38,代码来源:ResultActivity.java
示例5: getAmazonAuthorizationManager
import com.amazon.identity.auth.device.authorization.api.AmazonAuthorizationManager; //导入依赖的package包/类
public AmazonAuthorizationManager getAmazonAuthorizationManager(){
return mAuthManager;
}
开发者ID:vaibhavs4424,项目名称:AI-Powered-Intelligent-Banking-Platform,代码行数:4,代码来源:AuthorizationManager.java
示例6: logoutAndUnlink
import com.amazon.identity.auth.device.authorization.api.AmazonAuthorizationManager; //导入依赖的package包/类
private void logoutAndUnlink() {
//logout/unlink and wipe local dataset
//new CognitoUnlinkTask().execute();
Session session = Session.openActiveSessionFromCache(SnakeGameActivity.this);
if (session != null) {
session.closeAndClearTokenInformation();
}
AmazonAuthorizationManager mAuthManager = new AmazonAuthorizationManager(this, Bundle.EMPTY);
if (mAuthManager != null) {
mAuthManager.clearAuthorizationState(null);
}
AWSClientManager.getCognitoSync().wipeData();
Toast.makeText(gameView.getContext(), "Logout Successful",
Toast.LENGTH_SHORT).show();
}
开发者ID:aws-samples,项目名称:aws-mobile-self-paced-labs-samples,代码行数:24,代码来源:SnakeGameActivity.java
注:本文中的com.amazon.identity.auth.device.authorization.api.AmazonAuthorizationManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论