rides-android-sdk
rides-android-sdk copied to clipboard
"No authentication provided.",Internal Server Error.
Github issues are for bug reports. If this is a question around usage or understanding please use Stack Overflow. https://stackoverflow.com/questions/tagged/uber-api
Library version:0.9.1
Repro steps, stacktrace, screenshots:
// .............initial ubar sdk................ private void initializeUber() { if (!UberSdk.isInitialized()) { config = new SessionConfiguration.Builder() // mandatory .setClientId(Authentication.Clint_id) .setClientSecret(Authentication.Clint_secrect) // required for enhanced button features .setServerToken(Authentication.Server_token) // required for implicit grant authentication .setRedirectUri(Authentication.Redirect_uri) // optional: set sandbox as operating environment .setEnvironment(SessionConfiguration.Environment.SANDBOX) .setScopes(Arrays.asList(Scope.PROFILE, Scope.RIDE_WIDGETS, Scope.REQUEST, Scope.REQUEST_RECEIPT, Scope.ALL_TRIPS)) .build(); UberSdk.initialize(config); } }
public void AuthorizationAccess() {
LoginCallback loginCallback = new LoginCallback() {
@Override
public void onLoginCancel() {
// User canceled login
Toast.makeText(getApplicationContext(), "User canceled login", Toast.LENGTH_SHORT).show();
}
@Override
public void onLoginError(@NonNull AuthenticationError error) {
// Error occurred during login
Toast.makeText(getApplicationContext(), "Error occurred during login", Toast.LENGTH_SHORT).show();
}
@Override
public void onLoginSuccess(@NonNull AccessToken accessToken) {
// Successful login! The AccessToken will have already been saved.
Toast.makeText(getApplicationContext(), "Successful login! The AccessToken will have already been saved.", Toast.LENGTH_SHORT).show();
createSession();
}
@Override
public void onAuthorizationCodeReceived(@NonNull String authorizationCode) {
Toast.makeText(getApplicationContext(), "Authorization code received", Toast.LENGTH_SHORT).show();
createSession();
}
};
AccessTokenManager accessTokenManager = new AccessTokenManager(getApplicationContext());
LoginManager loginManager = new LoginManager(accessTokenManager, loginCallback, config, requestCode);
loginManager.setAuthCodeFlowEnabled(true);
loginManager.login(this);
mAccessTokenManager = accessTokenManager;
mLoginManager = loginManager;
}
private void createSession() {
try {
AccessToken accessToken = mAccessTokenManager.getAccessToken();
String s = String.valueOf(accessToken);
Log.d("tag", s);
Session session = mLoginManager.getSession();
service = UberRidesApi.with(session).build().createService();
service.getUserProfile().enqueue(new Callback<UserProfile>() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onResponse(@NonNull Call<UserProfile> call, @NonNull Response<UserProfile> response) {
Log.i(TAG, response.toString());
if (response.isSuccessful()) {
//Success
Toast.makeText(getApplicationContext(), "i am here", Toast.LENGTH_LONG).show();
UserProfile profile = response.body();
Log.d(TAG, Objects.requireNonNull(profile).getFirstName());
} else {
//Api Failure
ApiError error = ErrorParser.parseError(response);
assert error != null;
for (int i = 0; i < error.getClientErrors().size(); i++) {
Log.i(TAG, error.getClientErrors().get(i).getTitle());
Log.d("tag", "i am here with api error");
Toast.makeText(getApplicationContext(), "i am here with api error", Toast.LENGTH_LONG).show();
}
}
}
@Override
public void onFailure(Call<UserProfile> call, Throwable t) {
//Network Failure
Log.d("tag", "i am here with net fail");
Toast.makeText(getApplicationContext(), "i am here with api error2", Toast.LENGTH_LONG).show();
}
});
} catch (Exception ex) {
Log.d("uber", "failed creat profile");
Toast.makeText(getApplicationContext(), "i am here with api error3", Toast.LENGTH_LONG).show();
}
}
Expected Behavior: