OAuth Issues

I am creating a Smart App with Oauth enabled.
I am using the url calling from a Java/Rest client running locally on my laptop
https://graph.api.smartthings.com/oauth/authorize?client_id=XXX&reponse_type=code&scope=app&redirect_uri=http://localhost:8080/DeviceInfo/smartThings/oauth.

Issue1
I am always redirected to the login page not sure how to by pass that page and go into the authorization page?

Issue2
It is not getting redirected to the redirect url. The url it is redirecting is that I see in the browser
https://graph.api.smartthings.com/DeviceInfo/smartThings/oauth?code=bjSRcT

instead of the localhost where my code is running. It appends my uri DeviceInfo/smartThings/oauth. to smart things url
https://graph.api.smartthings.com.

Not sure what I am doing wrong. Any help is appreciated.

  1. You have to login first before you can authorize your devices.
    This is a fairly typical OAuth flow. Once you have authorized your devices, you’ll get a temporary code (as shown in Issue 2) which you can trade in for an OAuth token. Once you have the token, you will use that as your authorization and bypass the login with each future request.
  2. Try URL encoding your redirect URL:
    URL Decoder/Encoder

https://graph.api.smartthings.com/oauth/authorize?client_id=XXX&reponse_type=code&scope=app&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2FDeviceInfo%2FsmartThings%2Foauth1

1 Like

Thank you for the reply…

My flow is

  1. make a rest call to my java client .
  2. this java client makes a GET call to https://graph.api.smartthings.com/oauth/authorize?client_id=XXX&reponse_type=code&scope=app&redirect_uri=http://localhost:8080/DeviceInfo/smartThings/oauth
    Issue: it is not getting redirected to the login page for entering the login credentials.
    when I use the above url in browser it redirects to the login page correct.
    Not sure why it is not redirecting from the Java client?

Sudhakar,

I guess you were trying with something like apache httpclient.
Were you able to pass through authentication using HttpClient…? access your device…?

Or did you use some Oauth2 libraries in Java to solve this…

Any help is appreciated.