azure - Invalid JWT signature - Unable to fetch APP only Token For office 365. -
in golang, trying app token office 365, below code create jwt using singing token.this code working me long time. getting invalid signature.
i using open source package jwt : github.com/dgrijalva/jwt-go
using created jwt, making request office api app token. failed unauthorized access. extracted jwt request , decode using https://jwt.io/ shows jwt invalid signature, don't know why not working suddenly.
if jwt invalid signature not able fetch app token?
and code using long time,that time didn't face issue this.?
i have created app in old azure(manage.windowsazure.com) portal account. , moved new portal(portal.azure.com). there relate this.?
code creating jwt signing
token := jwt.new(jwt.signingmethodrs256) delete(token.header, "typ") token.header["alg"] = "rs256" token.header["x5t"] = "$base64thumbprint" token.claims["aud"] = "https://login.windows.net/" + {tenant id} + "/oauth2/token" token.claims["exp"] = time.now().add(time.hour * 72).unix() token.claims["iss"] = {your app client id} token.claims["jti"] = "3206bab9-5fbe-407e-69f6-2e4dc447741a" token.claims["nbf"] = (time.now().add(time.hour * 72).unix()) + 5000 token.claims["sub"] = {your app client id} // using private key of certificate sign token key, err := ioutil.readfile("../server.key") if err != nil { fmt.println("token::assertion():"+logging.getline()+":error>>", err.error()) return } o.tobj.assertjwt, err = token.signedstring(key) if err != nil { fmt.println("token::assertion():"+logging.getline()+":error>>", err.error()) return }
making request office api app token created jwt
apiurl := "https://login.windows.net" resource := o.tobj.tenant_id + "/oauth2/token" data := url.values{} redirecturi := redirecturi + "/admin" data.set("grant_type", "client_credentials") data.add("redirect_uri", redirecturi) data.add("resource", "https://outlook.office365.com/") data.add("client_assertion_type ", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer") data.add("client_assertion",{assertjwt})
i checked response.its not valid
401 unauthorized 401 http/1.1 1 1 map content-type:[application/json; charset=utf-8] expires:[-1] x-content-type-options:[nosniff] cache-control:[no-cache, no-store]
i suspect that, lack in validation due invalid signature.is right ?
Comments
Post a Comment