Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Missing access token #18

Open
tunm1228 opened this issue Dec 3, 2021 · 15 comments
Open

Error: Missing access token #18

tunm1228 opened this issue Dec 3, 2021 · 15 comments

Comments

@tunm1228
Copy link

tunm1228 commented Dec 3, 2021

After successful login, the function got an error MatrixSdk.startSession()

@tunm1228
Copy link
Author

tunm1228 commented Dec 3, 2021

Usage: import MatrixSdk from 'react-native-matrix-sdk';

MatrixSdk.configure('https://your-matrix-homeserver.org');

try {
// The credentials will be also saved to the MatrixSdk instance
// but they can be returned anyways.
const credentials = await MatrixSdk.login('test', 'test');

// Session will return MXSessionAttributes
const session = await MatrixSdk.startSession();

// Create room, invite person & send message
const roomCreation = await MatrixSDK.createRoom('@alice:your-matrix-homeserver.org');
const roomId = roomCreation.room_id;
const successMessage = await MatrixSDK.sendMessageToRoom(roomId, 'text', {
body: 'Hello Alice 🚀',
msgtype: 'm.text',
});
} catch (e) {
console.error(e);
}

@hannojg
Copy link
Collaborator

hannojg commented Dec 3, 2021

Whats the error you get?

@tunm1228
Copy link
Author

tunm1228 commented Dec 3, 2021

I got an error : Missing access token when call function MatrixSdk.startSession()

@tunm1228
Copy link
Author

tunm1228 commented Dec 3, 2021

image

@hannojg
Copy link
Collaborator

hannojg commented Dec 3, 2021

This is on iOS or android?

@hannojg
Copy link
Collaborator

hannojg commented Dec 3, 2021

You might want to try to set the credentials explicitly after the login:

      MatrixSDK.setCredentials(
        credentials.access_token,
        credentials.device_id,
        credentials.user_id,
        credentials.home_server,
        credentials.refresh_token
      );

await MatrixSDK.startSession()

@tunm1228
Copy link
Author

tunm1228 commented Dec 3, 2021 via email

@tunm1228
Copy link
Author

tunm1228 commented Dec 4, 2021

MatrixSDK.setCredentials(
        credentials.access_token,
        credentials.device_id,
        credentials.user_id,
        credentials.home_server,
        credentials.refresh_token
      );

i tried and it shows error "[ReferenceError: Can't find variable: MatrixSDK]"

@tunm1228
Copy link
Author

tunm1228 commented Dec 4, 2021

it doesn't seem to understand the function MatrixSDK.setCredentials?

@hannojg
Copy link
Collaborator

hannojg commented Dec 4, 2021

Oh no, it seems like you are on an old version. Which version are you using? Make sure you install 1.0.0-alpha74

@tunm1228
Copy link
Author

tunm1228 commented Dec 4, 2021

I'm using "react-native-matrix-sdk": "^1.0.0-alpha74"

@tunm1228
Copy link
Author

tunm1228 commented Dec 4, 2021

I have a look at the package https://github.com/matrix-org/matrix-js-sdk, can it be used with the application?

@hannojg
Copy link
Collaborator

hannojg commented Dec 4, 2021

yeah, i def recommend using this package. You need to install some more stuff to get it working correctly. Have a look at rn-matrix (https://aelequin.gitbook.io/rnm). It uses the JS SDK but makes the installation very easy

@tunm1228
Copy link
Author

tunm1228 commented Dec 4, 2021

Thanks bro, I will try this package

@tunm1228
Copy link
Author

tunm1228 commented Dec 4, 2021

Do you mean i have to install the necessary packages in this link https://aelequin.gitbook.io/rnm/getting-started/installation/core-required

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants