Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

oauth 2.0 - Error: invalid_request device_id and device_name are required for private IP

I was doing my development with Google Drive API using [localhost:8080]. Suddenly I felt to test it in my local deployment sandbox and it has IP address as [192.168.1.1:8080]. And as per that I changed the credential in developer console client callback URL. I am using OAuth2WebServerFlow to get the refresh token using user consent. Then in future I am using the refresh token and OAuth2WebServerFlow to authenticate the user. But I was surprised - I got the error:

  1. That’s an error. Error: invalid_request device_id and device_name are required for private IP:

I don't know what is happening or how can I fix it. What is going on, I don't understand

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

An alternative to editing a hosts file is to use the "Magic DNS" service http://xip.io/ or http://nip.io/ (see edit)

xip.io is a magic domain name that provides wildcard DNS for any IP address.Say your LAN IP address is 10.0.0.1. Using xip.io,

        10.0.0.1.xip.io   resolves to   10.0.0.1
    www.10.0.0.1.xip.io   resolves to   10.0.0.1
 mysite.10.0.0.1.xip.io   resolves to   10.0.0.1
foo.bar.10.0.0.1.xip.io   resolves to   10.0.0.1

With this service, you can specify a public-looking domain that resolves to a private address.

In the Console, if your Redirect URI was (what you wish you had anyways):

http://192.168.1.1:8080/auth/google_oath2/callback

Replace it with:

http://192.168.1.1.xip.io:8080/auth/google_oath2/callback

"Redirect URIs" does not seem to accept wildcards, so the entire private ip-xip.io needs to be specified in the console.

I have no affiliation with xip.io; I'm just a satisfied user.

2016 Edit: I've heard reports of instability with the xip.io DNS servers. There is a copy-cat service nip.io that behaves exactly the same as xip.io, but during July 2016, nip.io had a 100% response rate while xip.io did not.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...