react-uport-box
react-uport-box copied to clipboard
Error: JWT has expired
Was part of a hackathon a few months ago and we used the uport box to bootstrap the project. It was working then but not now. Trying to get this to work but continue receiving this error: Error: JWT has expired
.
Code we had working 2 months ago was: export let uport = new Connect('TruffleBox');
.
Project is at - https://github.com/micksabox/ethwaterloo2017
Any idea why this may be happening and how I can fix?
I think that's still the same line in src/util/connectors.js
. I have the same error, can't even login. I was at EthWaterloo too :)
This is due to clock on the device not being in sync.
Thanks @ingcoders, in sync with what exactly?
Problem is in given line for the used version of uport library: https://github.com/uport-project/uport-js/blob/e8803dc2b6f2bf4213ff188f1dd930cc01e4ba9a/src/JWT.js#L29
payload.exp
timestamp has 10 char but, new Date().getTime()
has 13. So even if payload.exp
bigger than current timestamp, because of this character difference current time is always bigger.
I think they solved this with their current version, but if you want to do quickfix this issue you can use simply;
Math.floor(new Date().getTime()/1000))
instead of
new Date().getTime()
I solved this by creating an app in uPort
- create an app in uport
- copy the code at the bottom under 'Click Here for your App Code'
- Change
import { Connect } from 'uport-connect
export let uport = new Connect('TruffleBox')
export const web3 = uport.getWeb3()
to
import { Connect, SimpleSigner } from 'uport-connect'
export const uport = new Connect('Test Ap 1', {
clientId: 'xxx',
network: 'rinkeby',
signer: SimpleSigner('xxx')
})
export const web3 = uport.getWeb3()
@wrannaman thanks man! can't believe i missed that haha
@wrannaman where did you add the requestCredentials
and attestCredentials
functions?
nvm it's in /src/user/ui/loginbutton/LoginButtonActions.js
, at least for requestCredentials
@wrannaman trying to integrate uport-connect with our DApp and this was a life saver today (in the #EthDenver2018 hackathon)! Thanks a bunch!
I just updated the uport-connect package to current version 0.7.1 and it worked.