react-uport-box icon indicating copy to clipboard operation
react-uport-box copied to clipboard

Error: JWT has expired

Open mokn opened this issue 7 years ago • 10 comments

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?

mokn avatar Dec 07 '17 12:12 mokn

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 :)

ToJen avatar Dec 16 '17 03:12 ToJen

This is due to clock on the device not being in sync.

ingcoders avatar Dec 16 '17 04:12 ingcoders

Thanks @ingcoders, in sync with what exactly?

ToJen avatar Dec 16 '17 16:12 ToJen

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()

mdtanrikulu avatar Dec 23 '17 16:12 mdtanrikulu

I solved this by creating an app in uPort

  1. create an app in uport
  2. copy the code at the bottom under 'Click Here for your App Code'
  3. 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 avatar Dec 24 '17 10:12 wrannaman

@wrannaman thanks man! can't believe i missed that haha

ToJen avatar Dec 24 '17 12:12 ToJen

@wrannaman where did you add the requestCredentials and attestCredentials functions?

ToJen avatar Dec 24 '17 13:12 ToJen

nvm it's in /src/user/ui/loginbutton/LoginButtonActions.js, at least for requestCredentials

ToJen avatar Dec 24 '17 13:12 ToJen

@wrannaman trying to integrate uport-connect with our DApp and this was a life saver today (in the #EthDenver2018 hackathon)! Thanks a bunch!

kishorebhatia avatar Feb 17 '18 18:02 kishorebhatia

I just updated the uport-connect package to current version 0.7.1 and it worked.

Ejdems666 avatar Mar 17 '18 19:03 Ejdems666