fixed the issue. Will look into that further If the access token is no longer valid you can rescue the Instagram::BadRequest exception:
@token = 'xXxXxX...'
@client = Instagram.client(access_token: @token)
user = @client.user
# YOUR LOGIC HERE
rescue Instagram::BadRequest => e
if e.message =~ /access_token provided is invalid/
# ACCESS TOKEN IS NO LONGER VALID
# DO SOMETHING E.G. SEND THE USER AN EMAIL
# IT RETURNED 400 FOR ANOTHER REASON
I hope this helps . Not sure what you are trying to do, but if you are just accessing APIs, then Yes, you can use one client_id/access_token to access APIs from multiple pages and also multiple websites.
around this issue The answer is No. In order to authenticate the Instagram user they need to be directed to Instagram. On successful login Instagram will return the user back to your site or another URL of your specification. (this is the redirect Uri)
wish help you to fix your issue There are no life long tokens by design. You'll have to implement logic to refresh a token when it expires. There is no way around this, you have to use an access token and you have to deal with the fact that tokens expire. It's on you, as the developer, to implement logic. From the documentation:
how to handle Instagram access token expired error