Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

How to switch between accounts ? #124

Closed
fiasko131 opened this issue Jun 28, 2017 · 7 comments
Closed

How to switch between accounts ? #124

fiasko131 opened this issue Jun 28, 2017 · 7 comments

Comments

@fiasko131
Copy link

fiasko131 commented Jun 28, 2017

I can not find a way to create multiple accounts and pass from one to the other. The code that i use to create one Account in my app:

final DefaultCallback<IOneDriveClient> callback = new DefaultCallback<IOneDriveClient>(getActivity()) {
                            @Override
                            public void success(final IOneDriveClient result) {

                                mOneDriveClient = result;
                                mOneDriveClient
                                        .getDrive()
                                        .buildRequest()
                                        .get(new ICallback<com.onedrive.sdk.extensions.Drive>() {


                                            @Override
                                            public void success(final com.onedrive.sdk.extensions.Drive onedrive) {
                                               
                                                new Thread(new Runnable() {
                                                    @Override
                                                    public void run() {
														//In this method I retrieve the account infos:
														//DriveId, quotas, displayName ....
                                                        createOneDriveAccount(onedrive);
                                                    }
                                                }).start();
                                            }
                                            @Override
                                            public void failure(ClientException ex) {
                                                Toast.makeText(getActivity(),"pas bon", Toast.LENGTH_SHORT)
                                                        .show();
                                            }
                                        });
                            }
                            @Override
                            public void failure(final ClientException error) {

                            }
                        };
                        new OneDriveClient
                                .Builder()
                                .fromConfig(createConfig())
                                .loginAndBuildClient(getActivity(), callback);

But I can not renew the operation to create and register another account. How can I access the microsoft login page again?

@daboxu
Copy link
Contributor

daboxu commented Jul 17, 2017

probably you can try

 oneDriveClient.getAuthenticator().logout();

to logout the current account you are using?

@fiasko131
Copy link
Author

fiasko131 commented Jul 18, 2017

@daboxu If I do this I can get a new client but if I want to reconnect to the precedent I have to redo a login with the authorization. How do I reconnect with the the obtained driveId (or accestoken?) and save in a file for example, without going back through the process?
So as with the other providers of cloud I can have several sessions and pass an object from one to the other.
Thank you.

@daboxu
Copy link
Contributor

daboxu commented Jul 18, 2017

that's a little bit tricky, if an access token works for your case, you can get it from the authenticator.

oneDriveClient.getAuthenticator().getAccountInfo().getAccessToken();

The MSA Authenticator we provided for OneDriveSDK is not intended for handling multiple sessions of user due to the underlying LiveAuthClient. So probably you can implements your own IAuthenticator which delegate the auth login work to MSAAuthenticator while store the access tokens by yourself?

And welcome to provide this feedback to the new Graph SDK and Graph Authenticator

@fiasko131
Copy link
Author

Yes i can get the acces tokens but i don't find the method to build a client with it... I don't understand why it 's so tricky to manage multiple session with this sdk. I will search with MSA Authenticator ...

@huntext17
Copy link

hi, were you able to get it working or find a workaround for this?

@fiasko131
Copy link
Author

fiasko131 commented Jun 25, 2018

@huntext17
No, and i don't understand why this basic feature is not supported!

@baywet
Copy link
Member

baywet commented Oct 2, 2024

Thank you for reaching out and for your patience. This SDK is being officially deprecated. See #172 for more information

@baywet baywet closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants